.htaccess 删除 "?page="
.htaccess remove "?page="
我有两个问题,都相关:
如何使用 .htaccess 将其写成:https://www.example.com/foo
第二部分
如何使用 .htaccess 将其写为:https://www.example.com/directory/bar
编辑:
回复请出示你当前的.htaccess
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
## Redirects the index.php file to the root domain
RewriteRule ^index.php$ https://www.digitleseo.com/ [R=301,L]
#redirect /file.php to /file
RewriteRule ^(.+).php$ / [L,R]
# now we will internally map /file to /file.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /.php [END]
这是我的文件 htaccess,我用它来删除控制器并将控制器名称保留为路径,将操作名称保留为路径。
<IfModule mod_rewrite.c>
RewriteEngine on
ErrorDocument 404 http://shop.local/error/index
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)/(.*) index.php?controller=&action=
</IfModule>
这应该适合你。
RewriteEngine on
#redirect /?page=foobar.php to /foobar
RewriteCond %{THE_REQUEST} \s/(?:index\.php)?\?page=([^.]+)\.php [NC]
RewriteRule .* /%1? [L,R]
###the rule bellow will internally forward the new URL to the old one
# not an existent file
RewriteCond %{REQUEST_FILENAME} !-f
#not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#rewrite the request /foo/bar to /?page=foo/bar.php
RewriteRule ^(.+)/?$ /?page=.php [L,END]
我有两个问题,都相关:
如何使用 .htaccess 将其写成:https://www.example.com/foo
第二部分
如何使用 .htaccess 将其写为:https://www.example.com/directory/bar
编辑:
回复请出示你当前的.htaccess
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
## Redirects the index.php file to the root domain
RewriteRule ^index.php$ https://www.digitleseo.com/ [R=301,L]
#redirect /file.php to /file
RewriteRule ^(.+).php$ / [L,R]
# now we will internally map /file to /file.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /.php [END]
这是我的文件 htaccess,我用它来删除控制器并将控制器名称保留为路径,将操作名称保留为路径。
<IfModule mod_rewrite.c>
RewriteEngine on
ErrorDocument 404 http://shop.local/error/index
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)/(.*) index.php?controller=&action=
</IfModule>
这应该适合你。
RewriteEngine on
#redirect /?page=foobar.php to /foobar
RewriteCond %{THE_REQUEST} \s/(?:index\.php)?\?page=([^.]+)\.php [NC]
RewriteRule .* /%1? [L,R]
###the rule bellow will internally forward the new URL to the old one
# not an existent file
RewriteCond %{REQUEST_FILENAME} !-f
#not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#rewrite the request /foo/bar to /?page=foo/bar.php
RewriteRule ^(.+)/?$ /?page=.php [L,END]