【发布时间】:2020-01-16 19:28:56
【问题描述】:
我需要
mysite.com/comment.php?id=sasdfkjsfj
重定向到
mysite.com/sasdfkjsfj.
现在,我正在使用此代码来执行此操作
RewriteEngine on
RewriteBase /
#redirect to remove comment.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /comment\.php\?id=([^\ &]+) [NC]
RewriteRule ^ %1? [L,R=301]
#process the SEF Url with comment.php
RewriteRule ^([-a-zA-Z]+)$ comment.php?id=$1 [L]
它将url地址更改为
mysite.com/sasdfkjsfj.
但这会导致 404 页面错误。我有一个单独的 comment.php 页面,它正在为
做这项工作 mysite.com/comment.php?id=sasdfkjsfj
我通过 $_GET['id'] 从 url 获取 id 但现在,如何处理
mysite.com/sasdfkjsfj
重定向后。
还有我必须对这种类型的 URL 进行哪些更改
mysite.com/sasdfkjsfj/Url_redirect_option.
【问题讨论】:
-
您是否通过
index.php处理您的cmets? -
@ThinkingMonkey 不,我有一个单独的页面comment.php。我想要的是在重定向之后如何显示之前由 mysite.com/comment.php?id=sasdfkjsfj 显示的内容
标签: php apache .htaccess mod-rewrite url-rewriting