简体   繁体   English

htaccess重写网址以隐藏php问号

[英]htaccess rewrite url to hide php question mark

my url format mysite/profile/?theusername with hide php extension, im trying to hide question mark in url so the url will like mysite/profile/theusername , looked up few posts about what i should do is add external redirect then internal forward in htaccess, tried lot of code still can't get it work. 我的网址格式为mysite/profile/?theusername具有hide php扩展名,我尝试在网址中隐藏问号,因此该网址将类似于mysite/profile/theusername ,查找了一些关于我应该怎么做的帖子:添加外部重定向,然后在内部转发htaccess,尝试过的许多代码仍然无法正常工作。 this is what i have now: 这就是我现在所拥有的:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /   

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

Keep your .htaccess like this: 保持您的.htaccess像这样:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /profile/

# new rules
RewriteCond %{THE_REQUEST} \s/+profile/?(?:index\.php)?\?([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ index.php?$1 [L,QSA]

# php hiding
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

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

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