【发布时间】:2018-09-10 10:56:22
【问题描述】:
我在地址http://example.com 有一个站点,它已被配置为删除 url 末尾的 .html(.php 等)并防止热链接事件(搜索引擎除外)。
我想建立一个包含http://us-en.example.com 等子域的多区域站点,并将所有内容从我当前的站点http://example.com 完全移动到http://us-en.example.com。
我有几个关于.htaccess 文件的问题:
问题 1
示例:
用户有一个像 http://example.com/images/all/image1 这样的“清晰”链接,但由于我移动了所有内容,因此该路径不包含图像并且不存在。
如何设置配置文件以将此“干净” url 重定向到“默认”子域 (us-en),从 http://example.com/images/all/image1 到 http://us-en.example.com/images/all/image1,但如果链接已经包含子域,则不执行任何操作?
问题 2
如何为所有子域正确设置.htaccess文件,使其具有与原始子域相同的功能(删除.html/.php并防止热链接)?
问题 3
如何从下面的模板中完成所有这些操作?
DirectoryIndex home.html
Options +MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?example\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !bing\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]
【问题讨论】:
-
你可以访问 apache .conf 文件吗?
-
是的,我愿意@DusanBajic
-
您的所有子域网站都在不同的文件夹中吗?
-
是的,他们是@DusanBajic
标签: apache .htaccess subdomain