我添加了一个
悬赏50英镑
对这个问题。我正努力做到:
-
所有网站页面均显示www.example。com/page/-而不是/page。我下面的当前代码仅适用于www.example。com/页
怎么可能。要实现这一点,需要更正htaccess代码吗?
另外,从www.mysite更改规范URL元标记。com/page至www.example。com/page/-will www.example。在搜索引擎中显示com/page/show而不是/page?
当前。htaccess代码为:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^ example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
请注意,第一个重写条件只是转发到www.和https,因此唯一需要编辑的部分可能是:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
所以我只想添加一个“/”。wordpress博客(可能是PHP文件而不是HTML)在同一个网站(www.example.com/blog/)上实现了我的愿望,其htaccess代码为:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
我不知道这是怎么回事,但我想了解更多。htaccess和重定向,但对于初学者来说,web上似乎没有什么内容。我也读过
this
邮递它也必须是https(不知道为什么,但博客帖子也可以有http链接,而其他页面重定向到https)。
该网站上还有一个博客(php文件),上面有自己的htaccess文件,安装在示例中。com/blog/-htaccess代码是默认的wordpress代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>