繁体   English   中英

Mod_rewrite - url重写不起作用

[英]Mod_rewrite - url rewriting isn't working

我一直试图让我的.htaccess文件中的mod_rewrite在过去几个小时内工作,但我似乎无法将它拉下来。 .htaccess文件肯定可以在我的服务器上运行,因为我之前使用过它们。

我试图用这个生成器重写它并使用这个工具以及我的服务器进行测试。

网址

我需要转

http://someurl.com/news-detail.html?id=10&news=this-is-an-article

http://someurl.com/news/10/this-is-an-article

要么

http://someurl.com/10/news/this-is-an-article

改写

我试过了:

RewriteEngine On
RewriteRule ^([^/]*)/news/([^/]*)$ /news-detail.html?id=$1&news=$2 [L]

RewriteEngine on
RewriteRule /(.*)/news/(.*) news-detail.html?id=$1&news=$2 [L]

RewriteEngine on
RewriteRule news/([0-9]+)/([a-zA-Z_]+)$ news-detail.html?id=$1&news=$2 [L]

和许多其他人。

我希望有人能在这里帮助我..

请在.htaccess文件中检查/添加RewriteBase。 还要检查是否允许htaccess重写。 语法如下

RewriteEngine on
RewriteBase /flodername/
RewriteRule ^urlinbrowser/(.*)/(.*)$ filename.php?first_param=$1&secondparam=$2 [L]

在root .htaccess中保留这样的规则:

RewriteEngine On
RewriteBase /dev/hoig/

RewriteCond %{THE_REQUEST} /news-detail\.html\?id=([^\s&]+)&news=([^\s&]+) [NC]
RewriteRule ^ %1/news/%2? [R=302,L]

RewriteRule ^([^/]+)/news/([^/]+)/?$ news-detail.html?id=$1&news=$2 [L,NC,QSA]

这将支持/10/news/this-is-an-article URI结构,用于漂亮的URL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM