[英]URL Rewriting doesn't rewrite automatically
I have this simple redirection on my website and it does not rewrite my url automatically, I have to type manual other URL to access it, what could be the problem, do I need to have something enabled in php.ini, below is the rewrite rule 我在我的网站上有这个简单的重定向,它没有自动重写我的网址,我必须输入手动其他URL来访问它,可能是什么问题,我需要在php.ini中启用一些东西,下面是重写规则
RewriteEngine On
RewriteRule ^new-page-([^/]*)\.php$ /mypage.php?name=$1 [L]
If you are doing it in .htaccess
you should also specify RewriteBase /
. 如果你在
.htaccess
中执行它,你还应该指定RewriteBase /
。 Try 尝试
RewriteEngine On
RewriteBase /
RewriteRule ^new-page-([^/]*)\.php$ mypage.php?name=$1 [L]
This rewrites new-page-something.php
to mypage.php?name=something
internally. 这
mypage.php?name=something
new-page-something.php
重写为mypage.php?name=something
内部。
ADDED: 添加:
Perhaps you want this: 也许你想要这个:
RewriteEngine On
RewriteBase /
RewriteRule ^new-page-([^/]*)\.php$ mypage.php?name=$1 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /mypage.php
RewriteCond %{QUERY_STRING} name=([^\&]*)
RewriteRule ^mypage.php$ new-page-%1.php? [R,L]
The first added RewriteCond checks whether the real request is requesting for /mypage.php
to prevent a redirect loop. 第一个添加的RewriteCond检查实际请求是否正在请求
/mypage.php
以防止重定向循环。 The second added RewriteCond is used to match the query string for use in RewriteRule. 第二个添加的RewriteCond用于匹配查询字符串以在RewriteRule中使用。
check your apache config (httpd.conf) see whether it allowing to overriding the htaccess 检查你的apache配置(httpd.conf)看看它是否允许覆盖htaccess
http://httpd.apache.org/docs/2.0/howto/htaccess.html http://httpd.apache.org/docs/2.0/howto/htaccess.html
I have the following link 我有以下链接
www.preparationweb.com/Aptitude/Discussion/index.php?qid=26
www.preparationweb.com/Aptitude/Discussion/index.php?qid=26
I like it to appear it as 我喜欢它看起来像
www.preparationweb.com/Aptitude/Discussion/26
www.preparationweb.com/Aptitude/Discussion/26
Can you please provide me the code to be placed in .htaccess file according to the provided link. 您能否根据提供的链接向我提供放在.htaccess文件中的代码。 I have a godaddy hosting.
我有一个godaddy托管。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.