apache rewrite 重写后出现 出现404 not found

求教各位亲了,帮个忙:
希望:我现在遇到如下问题,使用thinkphp框架,希望能够隐掉index.php;
已经操作过的:
1. LoadModule rewrite_module modules/mod_rewrite.so 已经去掉#,打开了
2. 也设置了
Options All
AllowOverride all
Order allow,deny
Allow from all
Require all granted

3.网站、thinkphp和php程序文件是从阿里云服务器下载的,在服务器上很正常,不过云上是linux+nginx,我这是windows下phpstudy(apcahe)。
4.htaccess文件配置是云服务上的,也是默认的

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

现在状态:首页:localhost可以打开,隐藏掉了index.php,首页在home目录下
子页面省略index.php无法显示,不省略显示正常。
例如:localhost/index.php/gur是正常的
localhost/gur 会显示Not Found
请问这是什么情况,应该怎么设置啊

1个回答

.htaccess重写规则支队apache生效,nginx需修改nginx配置文件:
location / {
include /var/www/.rewrite;
}
包含.rewrite文件,rewrite文件内容如下:
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1;
rewrite ^/Jact_robfaty/(.*)$ /Jact_robfaty/index.php/$1;
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

Apache mod重写不适用于mac os x lion

<div class="post-text" itemprop="text"> <p>I'm trying to set up mod rewrite on os x and it doesn't seem to be working properly.</p> <p>I've edited my httpd.conf file to include the module, I've changed the AllowOverride setting to "all" in both my httpd.conf and my user.conf file.</p> <p>Now when I add a htaccess file with the following:</p> <pre><code>RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] </code></pre> <p>I get a 404 not found saying ...</p> <p>"The requested URL /Users/matt/Sites/framework/public/ was not found on this server."</p> <p>Even though that folder does exist. </p> <p>The fact that it's redirecting would suggest that mod rewrite is installed and working, but I'm not sure why I'm getting a 404. Any one else had this problem?</p> <p>Thanks</p> </div>

Apache mod_rewrite:将路径重写为现有文件的查询字符串

<div class="post-text" itemprop="text"> <p>I am creating a simple redirect tool for myself in PHP. I'm going to store codes that map to their respective URLs in an associative array, and then redirect anybody who inputs this code to their URL.</p> <p>I am using query strings to GET the input (the name of the variable and the value, which is the code), and I already know how to make the redirect part work with PHP. The issue is, I don't want my users to have to type in a question mark, the name of the variable, and then an equals sign. I would like for them to simply type in a path that will be converted into a query string, so that PHP can process the redirection.</p> <p>I was wondering how I could turn a path (an arbitrary URL path) into a query string of an existing file. I was able to find the opposite task quite easily on Stack Overflow (<a href="https://stackoverflow.com/questions/27870258/htaccess-rewrite-query-string-and-redirect-to-directory">.htaccess - Rewrite query string and redirect to directory</a>) but I want to be able to pass any arbitrary URL path (that does not exist in the directory) into an existing file's query string. I found an example of what I wanted (<a href="https://stackoverflow.com/questions/23437534/url-rewrite-for-converting-path-to-querystring">URL rewrite for converting path to querystring</a>), but it was for multiple query strings and in this case, I only need one. I don't think the last question I referenced was successfully answered either.</p> <p>How can I redirect</p> <pre><code>https://www.example.com/r/blahblahblah </code></pre> <p>into</p> <pre><code>https://www.example.com/r/index.php?r=blahblahblah </code></pre> <p>using .htaccess, so that I can parse the query string in my PHP file?</p> </div>

Apache重写规则适用于localhost,但不适用于服务器

<div class="post-text" itemprop="text"> <p>I have a site that I would like to use Apache's RewriteRule to rewrite URLs. I want: </p> <ul> <li><a href="http://baileyseymour.com/index.php?p=home" rel="nofollow">http://baileyseymour.com/index.php?p=home</a><br> to rewrite to </li> <li><a href="http://baileyseymour.com/p/home" rel="nofollow">http://baileyseymour.com/p/home</a></li> </ul> <p>I have AMPPS installed on my Mac and I added the following lines to <code>httpd.conf</code> and they work successfully:</p> <pre><code>RewriteEngine On RewriteRule ^/p/(.*) /index.php?p=$1 [PT] </code></pre> <p>I'm trying to do the same but on my server. And I have added the same apache code to <code>/public_html/.htaccess</code> but I get the error message below:</p> <blockquote> <p><strong>Not Found</strong><br> The requested URL /p/home was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p> </blockquote> <p>The exact same code works on my localhost server. Why not on my website?</p> </div>

thinkPHP 5 本地访问报The requested URL / was not found on this server.

我在本地用Apache搭建thinkPHP5 重写路由后访问报The requested URL / was not found on this server. ![图片说明](https://img-ask.csdn.net/upload/201907/01/1561946656_30395.png) 我入口文件是有.htaccess文件的 ``` <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] </IfModule> ``` 那为什么还会报这个错了

刚刚启动apache .htaccess重写到lighttpd转换

<div class="post-text" itemprop="text"> <p>Below is my .htaccess file from apache. I'm getting a 404 not found error on my subdirectories, and I am certain it has to do with my rewrite.</p> <pre><code>Options -Indexes Options +FollowSymLinks &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* file.php [L,QSA] &lt;/IfModule&gt; </code></pre> <p>Here is my lighttpd.conf rewrite</p> <pre><code>$HTTP["host"] =~ "www.example.com" { url.rewrite = ( "^(.*)$" =&gt; "$1.php" ) } server.follow-symlink = "enable" </code></pre> <p>I know the "$1.php" isn't the right answer. It sort-of works, but I wouldn't consider it functional. It's sole purpose here is to help put together what I'm trying to do.</p> </div>

Dockerfile启动PHP容器,mysqli和a2enmod重写不起作用

<div class="post-text" itemprop="text"> <p>I'm trying to start a container based on a dockerfile. it shoud have mysqli and a2enmod.</p> <p>My Dockerfile is</p> <pre><code>FROM php:7.1-apache RUN docker-php-ext-install mysqli &amp;&amp; a2enmod rewrite &amp;&amp; service apache2 restart </code></pre> <p>but the a2enmod is not enablad before start. When I Attach to the container bash I got that a2enmod was not enabled</p> <pre><code>$ a2enmod rewrite Enabling module rewrite. To activate the new configuration, you need to run: service apache2 restart $ a2enmod rewrite Module rewrite already enabled </code></pre> <p>What am I doing wrong?</p> </div>

镆铘。 Apache URL重写问题

<div class="post-text" itemprop="text"> <p>I faced with URL rewrite issue. Please help me to understand where is the problem or show me the way where to look.</p> <p>Before the issue appeared I moved my modx evo to another host. There I faced with compatiblity issue. I used modx 1.0.6. On server installed php 5.5 (I can't find information about compatibility modx and php5.5. Everything except url rewrite is working well). I upgraded modx to 1.0.15</p> <p>So to reproduce the issue you need to enable frendly urls and open any page. You get following error:</p> <pre><code>Not Found The requested URL /gallery was not found on this server. Apache/2.4.7 (Ubuntu) Server at zvezda-vostoka.ru Port 80 </code></pre> <p>Here is htaccess:</p> <pre><code>php_flag register_globals Off AddDefaultCharset utf-8 php_value date.timezone Europe/Moscow Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC] RewriteRule .* - [F,L] RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.zvezda-vostoka\.ru [NC] RewriteRule (.*) http://www.zvezda-vostoka.ru/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </code></pre> </div>

Apache2:AH01630客户端在重写后被服务器配置拒绝

<div class="post-text" itemprop="text"> <p>I get this error, when trying to access a url which gets rewritten internally and I don't know why or how to fix it:</p> <pre><code>[Sun Apr 01 10:XX:XX.042734 2018] [authz_core:error] [pid 20813] [client 84.XX.XX.90:16450] AH01630: client denied by server configuration: /dev/home.php </code></pre> <p>Basically, I am trying to rewrite all html requests, so when you e.g. try to access /dev/file.html, it's rewriting it to dev/file.php</p> <p>I am able to access /dev/file.php without issues, but when I try to access /dev/file.html (which should point to the .php file) I am getting a 403 Forbidden error.</p> <p>I have tried several things, I found here on Stackoverflow, as well as in various blogs, but nothing helped. My current vhost conf looks like this:</p> <pre><code> &lt;VirtualHost *:80&gt; ServerName www.example.com # My actual files contain the correct domain and not "example" ServerAdmin admin@example.com DocumentRoot /var/www/html #Include /var/www/html/.htaccess ServerAlias www.example.com ServerAlias *.example.com &lt;Directory /&gt; Options FollowSymLinks AllowOverride None &lt;/Directory&gt; &lt;Directory /var/www/&gt; Options Indexes FollowSymLinks MultiViews #AllowOverride None Require all granted # since 2.4 &lt;/Directory&gt; #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined #Include conf-available/serve-cgi-bin.conf # Redirects Include /etc/apache2/redirects.conf # Doing all redirects/ rewrites here &lt;/VirtualHost&gt; </code></pre> <p>My redirects.conf file looks like this:</p> <pre><code>Options +FollowSymLinks RewriteEngine on Redirect 302 "/index.html" "http://example.com/maintenance.html" Redirect 302 "/index" "http://example.com/maintenance.html" RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)\.html$ $1.php </code></pre> <p>I am hosting the website using a virtual instance on google cloud, Ubuntu 16.04 and my Apache version is 2.4.18.</p> <p>I would greatly appreciate any hint! I am normally used to Node serving, so the conf stuff in apache is quite unusual to me.</p> <p>Thanks!</p> </div>

我有问题阻止Apache重写URL,即使重启后也是如此

<div class="post-text" itemprop="text"> <p>All I want to do is be able to see a PHP file from the root without it going through the rewrites (thus our custom CMS). </p> <p>Here's what I've done:</p> <ol> <li>In my httpd.conf, I've commented out the call to load the mod_rewrite module. </li> <li>Next, I've removed the .htaccess file from the root as it had the rewrite rules in it.</li> <li>I've rebooted the server.</li> <li>I've searched through phpinfo() and there are no "rewrite" strings to be found</li> </ol> <p>The problem is that the server still rewrites and the request passes through our CMS. </p> <p>I'm using XAMP (PHP 3.3.1, Apache 2.2.14)</p> <p>What am I missing?</p> </div>

找不到对象! 网址重写

<div class="post-text" itemprop="text"> <p>I have rewrited my url's with htaccess and now I the following URL</p> <p>This is my old URL:</p> <pre><code>http://example.com/user.php?username=collins1 </code></pre> <p>The new URL:</p> <pre><code>http://example.com/user/collins1/ </code></pre> <p>The .htaccess file:</p> <pre><code>Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^user\.php$ %{QUERY_STRING} [C] RewriteRule ^username=(.*) /user/$1/? [R=301,L] </code></pre> <p>It get an Object not found! response, kindly help</p> </div>

htaccess URL重写中的递归重定向(Apache中的mod_rewrite)

<div class="post-text" itemprop="text"> <p>In the root folder of my project there are several other folders I am calling "apps". The path to one of these apps is something like: </p> <p><strong>/root_folder/myapp/...</strong></p> <p>There are actually a dozen apps like this. So I want my project to be using friendly URLs, and to achieve that I am using the apache module <strong>mod_rewrite</strong>. </p> <p>I added the following rule to my .htaccess (that is in root_folder, just so you to know) <code>RewriteRule ([^/]*)/(.*)?$ myDomain.com/$1/index.php?params=$2 [NC,L]</code></p> <p>So an URL such as mydomain/myApp/param/value/param2/value would be translated to mydomain/myApp/index.php?params=value/param2/value</p> <p>I performed some tests and saw it working until I added the $1 to refer to the app folder (have a look: the_path_to_my_root_folder_here/<strong>$1</strong>/index.php?params=$2)</p> <p>It is generating an URL like: myDomain.com/myApp/index.php?params=index.php</p> <p>Well I thought it would be a recursion issue. So it seems that Apache will try another redirection afther the first is performed, and then it will generate an URL like that </p> <p>I found this thread in Stackoverflow <a href="https://stackoverflow.com/questions/8953895/url-rewrite-recursively/8957377">url rewrite recursively</a> The problem with the answer is that it`s assuming I know when to stop.</p> <p>Do you know how to make this second redirection to stop?</p> <p>Thanks</p> <p>@EDIT</p> <p>I am trying the following rule now <code>RewriteRule myDomain.com/([A-Za-z0-9-]+)/(.*)$/ myDomain.com/$1/index.php?params=$2 [NC,L]</code></p> <p>But it's not working properly. It is only matching the regex, if I do not pass parameters after the app name. so when I try myDomain.com/user/ it works (not receiving parameters), and fails when I try myDomain.com/user/products/1000/, for example. Instead of rewriting/redirecting, it is trying to find a folder <strong>products</strong> inside <strong>user</strong> and etc</p> </div>

从$到$ .php添加重写后,nginx CSS中断

<div class="post-text" itemprop="text"> <p>If I will add the following line to my nginx configuration it will break my website and will run without CSS: </p> <pre><code>location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|svg|xml)$ { access_log off; expires 30d; } location / { try_files $uri $uri/ $uri.php =404; rewrite ^/(.+)$ /$1.php last; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } </code></pre> <p>if I comment the rewrite condition everything will work fine. </p> <p>What can I do to bring both things to work, the rewrite condition and the css style sheet?</p> <p>Edit: I got a new problem, now all files like <code>test.php</code> work fine without writing <code>.php</code>, but folders like <code>users/</code> won't work, I still reveive <code>File not found</code>, normaly it should take the <code>index.php</code> or <code>index.html</code> from the folder, how can I provide both functions? add <code>.php</code> to files and use <code>inde.php/html</code> from folder?</p> </div>

当URL包含%字符时使用Apache重写模块向每个%添加“52”

<div class="post-text" itemprop="text"> <p>I need to modify the path of a long URL which includes % characters in it, for example:</p> <pre><code>https://www.my-geoserver.co.uk/geoserver/HNT_Demo/wms?SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetMap&amp;FORMAT=image%2Fpng&amp;TRANSPARENT=true&amp;LAYERS=HNT_Demo%3ANO2_Wed_h18_WGS&amp;TILED=true&amp;login=admin&amp;WIDTH=256&amp;HEIGHT=256&amp;CRS=EPSG%3A3857&amp;STYLES=&amp;BBOX=-132083.18487678468%2C6780270.1570082735%2C-127191.2150665334%2C6785162.126818525 </code></pre> <p>When i attempt to use Apache rewrite module, I notice that the % characters are causing problems, so for example the section here:</p> <pre><code>image%2Fpng </code></pre> <p>Upon rewrite becomes (notice 52 has appeared):</p> <pre><code>image%252Fpng </code></pre> <p><code>%2F</code> is the URL Encoded value of a forward slash, so I can't believe this is an uncommon problem.</p> <p>The code I'm using (for experimental purposes) is:</p> <pre><code>RewriteCond %{QUERY_STRING} ^(.*)login=[^&amp;]*(?:&amp;(.*)|)$ [NC] RewriteRule ^ %{REQUEST_URI}?%1%2 [R=301,L] </code></pre> <p>Which should simply remove the login variable which it does. But I also get a modification of the % values throughout the URL, where in all cases <code>52</code> is appearing which I don't think is related to the RewriteRule per say.</p> <p>Is there a way to allow RewriteRule to work with % values in the URL? I have tried the following flags (somewhat desperately):</p> <ul> <li>NC </li> <li>NE </li> <li>QSA</li> </ul> <p>But with no luck.</p> <p><strong>Additional:</strong></p> <p>I've just found this very old bug report which shows the same behavior of % being 'escaped' to %25. Is this possibly a bug?</p> <p><a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=39746" rel="nofollow noreferrer">https://bz.apache.org/bugzilla/show_bug.cgi?id=39746</a></p> <p>This bug is referring to using a reverse proxy and the error being in mod_proxy, well I'm using a reverse proxy to host Tomcat, could this be related?</p> <p><strong>Additional 2:</strong></p> <p>The answer to a question here:</p> <p><a href="https://stackoverflow.com/questions/41737618/the-auto-urldecode-in-apache-mod-rewrite/43176073#43176073">the auto urldecode in apache mod_rewrite</a></p> <p>Suggests using server variables to get around the % issue, unfortunately, I already am using them. I tried replacing QUERY_STRING with REQUEST_URI and THE_REQUEST, both of which result in the same behaviour:</p> <pre><code>RewriteCond %{THE_REQUEST} ^(.*)login=[^&amp;]*(?:&amp;(.*)|)$ [NC] RewriteRule ^ %{REQUEST_URI}?%1%2 [R=301,L] </code></pre> </div>

URL重写不能正常使用.htaccess

<div class="post-text" itemprop="text"> <p>I have implemented my small website on a live server, however I want to use url-rewrite for some links to make it clean. I try this on my localhost server:</p> <p><code>http://localhost/cb/2/login.php</code> to <code>http://localhost/cb/2/login</code></p> <p>I manage to make it work on my localhost server by editing the <code>httpd.conf</code> of apache and enable url-rewrite. Here's the rule I added to apache:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/cb/2/login$ /cb/2/login.php &lt;/IfModule&gt; </code></pre> <p>However, when I upload my files to a live server, obviously I do not have privilege to edit <code>httpd.conf</code> of that server, so I just put my rewrite rule on <code>.htaccess</code> file and here's the content of it:</p> <pre><code>RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/login$ /login.php [L,QSA,NC] </code></pre> <p>But when I try to test it, <code>404 not found</code> is the response of server. I also try to implement in on my localhost server assuming I cannot edit the apache config and same error occurs, <code>Object not found!</code></p> <p>I have no idea what will I do next. I'm new to this url rewrite rule so any help will be much appreciated :)</p> </div>

htaccess重写原始URL

<div class="post-text" itemprop="text"> <p>I am creating SEO friendly URLs for my website. I have a file notfound.php to which I am redirecting all the URLs. Now, I want notfound.php to search for the URL in database and generate the corresponding content.</p> <p>But the problem is that in the URL it shows is <code>http://some_url/notfound.php</code> I don't want this URL to be displayed in the address bar, instead I want the original one.</p> <p>For example,</p> <p><code>http://some_url/hello/world</code> is redirecting to <code>http://some_url/notfound.php</code> using <code>ErrorDocument 404</code> and notfound.php is serving the content</p> <p>But how to show <code>http://some_url/hello/world</code> in the URL instead of notfound.php? And, is this the right way to redirect and rewrite while matching the URLs from a database?</p> </div>

.htaccess URL为Yourls重写失败 - 在此服务器上找不到请求的URL

<div class="post-text" itemprop="text"> <p>Apache/PHP newbie question:</p> <p>I'm trying to get an installation of <code>http://yourls.org/</code> to work.</p> <p>All seems to have installed OK, and I can add new urls and it shortens them.</p> <p>However the links generated 404. E.g. <code>http://mydoma.in/4</code> should redirect but doesn't</p> <p>The .htaccess file looks like this:</p> <pre><code># BEGIN YOURLS &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /yourls-loader.php [L] &lt;/IfModule&gt; # END YOURLS </code></pre> <p>and if I browse to the page <code>http://mydoma.in/yourls-loader.php</code> it does redirect me to the homepage.</p> <p>I'm guessing there needs to be a parameter for the ID that needs passing via the rewrite to the <code>/yourls-loader.php</code> </p> <p>The <code>/yourls-loader.php</code> looks like this:</p> <pre><code>&lt;?php // Handle inexistent root favicon requests and exit if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { header( 'Content-Type: image/gif' ); echo base64_decode( "R0lGODlhEAAQAJECAAAAzFZWzP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0PUQAgSGoNQFt0LWTVOE6GuX1H6onTVHaW2tEHnJ1YxPc+UwAAOw==" ); exit; } // Handle inexistent root robots.txt requests and exit if ( '/robots.txt' == $_SERVER['REQUEST_URI'] ) { header( 'Content-Type: text/plain; charset=utf-8' ); echo "User-agent: * "; echo "Disallow: "; exit; } // Start YOURLS require_once( dirname( __FILE__ ) . '/includes/load-yourls.php' ); // Get request in YOURLS base (eg in 'http://site.dom/yourls/abcd' get 'abdc') $request = yourls_get_request(); // Make valid regexp pattern from authorized charset in keywords $pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() ); // Now load required template and exit yourls_do_action( 'pre_load_template', $request ); // At this point, $request is not sanitized. Sanitize in loaded template. // Redirection: if( preg_match( "@^([$pattern]+)/?$@", $request, $matches ) ) { $keyword = isset( $matches[1] ) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword( $keyword ); yourls_do_action( 'load_template_go', $keyword ); require_once( YOURLS_ABSPATH.'/yourls-go.php' ); exit; } // Stats: if( preg_match( "@^([$pattern]+)\+(all)?/?$@", $request, $matches ) ) { $keyword = isset( $matches[1] ) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword( $keyword ); $aggregate = isset( $matches[2] ) ? (bool)$matches[2] &amp;&amp; yourls_allow_duplicate_longurls() : false; yourls_do_action( 'load_template_infos', $keyword ); require_once( YOURLS_ABSPATH.'/yourls-infos.php' ); exit; } // Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows) if( preg_match( "@^[a-zA-Z]+://.+@", $request, $matches ) ) { $url = yourls_sanitize_url( $matches[0] ); if( $parse = yourls_get_protocol_slashes_and_rest( $url, array( 'up', 'us', 'ur' ) ) ) { yourls_do_action( 'load_template_redirect_admin', $url ); $parse = array_map( 'rawurlencode', $parse ); // Redirect to /admin/index.php?up=&lt;url protocol&gt;&amp;us=&lt;url slashes&gt;&amp;ur=&lt;url rest&gt; yourls_redirect( yourls_add_query_arg( $parse , yourls_admin_url( 'index.php' ) ), 302 ); exit; } } // Past this point this is a request the loader could not understand yourls_do_action( 'loader_failed', $request ); yourls_redirect( YOURLS_SITE, 302 ); exit; </code></pre> <p>The yourls_get_request() function looks like this:</p> <pre><code>function yourls_get_request() { // Allow plugins to short-circuit the whole function $pre = yourls_apply_filter( 'shunt_get_request', false ); if ( false !== $pre ) return $pre; static $request = null; yourls_do_action( 'pre_get_request', $request ); if( $request !== null ) return $request; // Ignore protocol &amp; www. prefix $root = str_replace( array( 'https://', 'http://', 'https://www.', 'http://www.' ), '', YOURLS_SITE ); // Case insensitive comparison of the YOURLS root to match both http://Sho.rt/blah and http://sho.rt/blah $request = preg_replace( "!$root/!i", '', $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 1 ); // Unless request looks like a full URL (ie request is a simple keyword) strip query string if( !preg_match( "@^[a-zA-Z]+://.+@", $request ) ) { $request = current( explode( '?', $request ) ); } return yourls_apply_filter( 'get_request', $request ); } </code></pre> </div>

URL重写/ Mod重写Apache和PHP上的.htaccess

<div class="post-text" itemprop="text"> <p>I have a single point of entry on my website</p> <p><code>mysite.com/admin/index.php?<strong>View=List&amp;Model=User</strong></code></p> <p>All access to the DB/application is through this index.php file.</p> <p>I would like to clean my URL from what is shown above to.</p> <p><code>mysite.com/admin/<strong>List/User</strong></code></p> <p>The idea is to remove the key 'Model and 'View'.</p> <p>I have found this link that looks very similar.</p> <p><a href="https://stackoverflow.com/questions/6982235/php-apache-rewrite-rules-with-htaccess">PHP/Apache: Rewrite rules with .htaccess</a></p> </div>

如何使用apache重写来重写从/ admin / recurring / foobar / 123到/ admin / recurring / public / foobar / 123的所有流量

<div class="post-text" itemprop="text"> <p>I just installed laravel into /admin/recurring but then I found out that all the goods are in public/ How do I point all traffic coming into /admin/recurring/foo/bar/123 to actually call the request to /admin/recurring/public/foo/bar/123</p> <p>Here is what I tried:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #This last condition enables access to the images and css folders, and the robots.txt file RewriteCond $1 !^(index\.php|public|images|robots\.txt|css) RewriteRule ^(.*)$ public/index.php/$1 [L] &lt;/IfModule&gt; </code></pre> <p>But this does not work. It gives me a Sorry, the page you are looking for could not be found. in Laravel 5.3</p> </div>

我看到该页面并获得一个404,其中包含由WordPress重写api指导的页面

<div class="post-text" itemprop="text"> <p>I have a strange problem. I hope someone can help me.</p> <p>So, in my new WordPress theme, I want to have iframes with a nice URL like mydomain.com/go/iframe1/</p> <p>So i registered a new Rewrite Rule with <code>add_rewrite_tag</code> and <code>add_rewrite_rule</code>. Okay, works fine so far, I go to my URL and the iframe shows up. But in my Apache-Logs and with Firebug I get 404 Not Found.</p> <p>The Rewrite Rule looks like this:</p> <pre><code>add_rewrite_rule( '^go/(.*)/?', 'wp-content/themes/mytheme/includes/rewrite/go.php', 'top' ); </code></pre> <p>So I execute the Script go.php.</p> <p>The go.php includes the <code>wp-blog-header.php</code> to have access to the WP functions. And here it looks like the problem occurs. If I don't include the <code>wp-blog-header.php</code> it works just fine.</p> <p>What makes me wonder is, that I have other Rewrite-Rules with the same inclusion without the 404 problem. So I think, there needs to be a solution. I thought maybe the slug 'go' would be a problem, but also another like 'iframe' produced the same problem.</p> <p>It would be very nice if someone could help me out here.</p> <p>Thanks a lot!</p> </div>

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问
相关内容推荐