2016-09-18 70 views
0

我刚刚意识到,我的一些改写的网址停止工作。我不知道为什么。重写URL似乎写错了

这是我重写文件

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^forums/([^/]*)/locate/([^/]*)/$ /forums.php?page=$1&tlocate=$2 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^changelogs/([^/]*)/$ /index.php?page=$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^forums/$ /forums.php 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]*)/$ /forums.php?page=$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^forums/action/([^/]*)/$ /forums.php?page=$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^forums/([^/]*)/section/([^/]*)/$ /forums.php?page=$1&sectionid=$2 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^register/([^/]*)/$ /register.php?page=$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^account/([^/]*)/$ /account-page.php?page=$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^about-us/$ /about.php 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^forums/([^/]*)/topic/([^/]*)/$ /forums.php?page=$1&topic=$2 [L] 

ErrorDocument 400 /error.php 
ErrorDocument 401 /error.php 
ErrorDocument 403 /error.php 
ErrorDocument 404 /error.php 
ErrorDocument 500 /error.php 

如果我去www.localhost/account/

这将只是给我发来www.localhost/forums/

所以,我下载的Mozilla浏览器,看看我的htaccess停止工作。该CSS没有在那里工作。然后我去了一个网站来检查我的代码,并抱怨线

RewriteRule ^about-us/$ /about.php 

在那行,我试图重写www.localhost/about.phpwww.localhost/about-us/

没有任何成功。我做错了什么导致了这个问题?

回答

0

您可以在.htaccess使用:

# skip all files and directories from rewrite rules below 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

RewriteRule ^forums/([^/]*)/locate/([^/]*)/$ /forums.php?page=$1&tlocate=$2 [L] 
RewriteRule ^changelogs/([^/]*)/$ /index.php?page=$1 [L] 
RewriteRule ^forums/$ /forums.php [L] 
RewriteRule ^forums/action/([^/]*)/$ /forums.php?page=$1 [L] 
RewriteRule ^forums/([^/]*)/section/([^/]*)/$ /forums.php?page=$1&sectionid=$2 [L] 
RewriteRule ^register/([^/]*)/$ /register.php?page=$1 [L] 
RewriteRule ^account/([^/]*)/$ /account-page.php?page=$1 [L] 
RewriteRule ^about-us/$ /about.php [L] 
RewriteRule ^forums/([^/]*)/topic/([^/]*)/$ /forums.php?page=$1&topic=$2 [L] 
RewriteRule ^([^/]*)/$ /forums.php?page=$1 [L] 

ErrorDocument 400 /error.php 
ErrorDocument 401 /error.php 
ErrorDocument 403 /error.php 
ErrorDocument 404 /error.php 
ErrorDocument 500 /error.php 

而在你about.php HTML代码添加以下代码:

<base href="/"> 

因为你改变了根目录(CSS和其他亲属)与about-us/链接。

+1

你是我的朋友,我已经有了一个底标。但其余的工作 – Synyster