mod_rewrite不能使用我的简单网址

时间:2014-04-05 02:47:32

标签: .htaccess mod-rewrite

问题是我无法使用mod_rewrite更改URL,我的URL是:

http://example.org/files/news.php?news=180


我希望看到这样的事情:

http://example.org/files/news/180

我已经尝试过这些代码(每一个评论的RewriteRule):

# Do not remove this line, otherwise mod_rewrite rules will stop working
# RewriteBase /
ErrorDocument 404 http://mysite.org/notfound.php

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /files/
#RewriteRule ^(.*)/ news.php?news=$1
#RewriteRule ^/news/([0-9]+) /news?news=$1
#RewriteRule ^(.*)/ files/news.php?news=$1 [L]
RewriteRule ^(.*)/(.*)/ news.php?news=$1 [L]

没什么,代码应该怎么样?感谢

1 个答案:

答案 0 :(得分:1)

将此代码放在/files/.htaccess

ErrorDocument 404 http://mysite.org/notfound.php

Options +Indexes +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /files/

RewriteRule ^news/([^/.]+)/?$ news.php?news=$1 [L,QSA]