htaccess用godaddy重写

时间:2012-04-26 17:35:16

标签: .htaccess mod-rewrite

尝试我的.htaccess页面重写此网址

www.mywebsite.com/view.php?2012/this-is-page.html

www.mywebsite.com/view.php/2012/this-is-page.html

“view.php”是模板......我只是不喜欢“view.php?”

最后让这个CMS使用“?”工作在“view.php”而不是“/”之后 - 现在,如何在浏览器URL窗口中重写它?

到目前为止,我有:

#Fix Rewrite
Options -Multiviews

RewriteEngine on

1 个答案:

答案 0 :(得分:2)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# external redirect from view.php?2012/this-is-page.html to view/2012/this-is-page.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+view\.php\?([^\s]+) [NC]
RewriteCond ^ view/%1? [L,R]

# internal forward from view/2012/this-is-page.html to view.php?2012/this-is-page.html
RewriteCond ^view/(.+)$ view.php?$1 [L,NC,QSA]