关于我的问题我在这里找到了更多解决方案stockoverflow和许多其他网站。但所有这些htaccess规则对我都不起作用。
我想从userprofile?user=
userprofile?user=myname
来自Godaddy的我的域名和来自onelancer的托管 Apache版本2.2.27 PHP版本5.4.28
我不知道htaccess规则?
我当前的网址如下:domain.com/myfolder/userprofile?user = .myname
隐藏了来自网址的
在这里,我已经通过htaccessmyfolder
我的.htaccess :(在网站根目录)
### Removed myfolder ### ( Working well )
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+myfolder/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^myfolder/)^(.*)$ /myfolder/$1 [L,NC]
### Remove userprofile?user= ### ( Not working - 500 error of all page )
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+userprofile\?user=([^&\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ userprofile?user=$1 [L,QSA]
答案 0 :(得分:0)
这样做:
root .htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+myfolder/userprofile\?user=([^&\s]+) [NC]
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{THE_REQUEST} \s/+myfolder/(\S*) [NC]
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!^myfolder/).*)$ /myfolder/$1 [L,NC]
<强> /myfolder/.htaccess:强>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /myfolder/
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ userprofile?user=$1 [L,QSA]