Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用.htaccess删除url的一部分_Apache_.htaccess - Fatal编程技术网

Apache 使用.htaccess删除url的一部分

Apache 使用.htaccess删除url的一部分,apache,.htaccess,Apache,.htaccess,有一段时间我的页面结构是这样的: 现在我想将其更改为: 我怎样才能做到最好 这是我已经拥有的: RewriteEngine On # Include "www" and change "http" to "https". RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} off RewriteRule

有一段时间我的页面结构是这样的:
现在我想将其更改为:

我怎样才能做到最好

这是我已经拥有的:

RewriteEngine On

# Include "www" and change "http" to "https".
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Ignore some stuff.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# The page part.
RewriteRule ^([a-zA-Z0-9/_\-]+)$ index.php?mode=page&slug=$1 [NC]
RewriteRule ^([a-zA-Z0-9/_\-]+)/$ index.php?mode=page&slug=$1 [NC,L]

# Redirect /page/SLUG to /SLUG?
大概是这样的:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^page/(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^page/(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTPS} on
RewriteRule ^page/(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

试试下面的条件和规则

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9/_\-]+)/?$ index.php?mode=page&slug=$1 [NC,L]

如果请求方案为https,则不会重定向请求。