我的目录设置如下:
mywebsite/directory1/index.php
mywebsite/directory2/index.php
mywebsite/directory3/index.php
mywebsite/directory4/index.php这是不友好的搜索引擎优化。如何使用mod_rewrite执行以下操作:
mywebsite/directory1/
mywebsite/directory2/
mywebsite/directory3/如何让搜索引擎抓取我的网站,而不会有多个index.php´s的问题?
你有什么专业的建议?
发布于 2010-11-28 03:06:28
将以下代码放入根.htaccess文件中:
RewriteEngine On
#if your index.php is located in the root folder:
RewriteBase /
#or use that, if the path for your index.php is '/some/subfolder/index.php':
#RewriteBase /some/subfolder/
#rewriting only if the request file doesn't exists (you don't want to rewrite request for images or other existing files)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)? index.php?path=$1 [L]在此之后,您可以在根index.php文件中使用REQUEST_URI:
var_dump($_SERVER['REQUEST_URI']);或者您可以使用$_GET‘’path‘
var_dump($_GET['path']);在HTML和CSS中,对图像和其他资源使用绝对路径(或者最好使用完整URL):
<img src="/image/image.jpg" alt="image" />https://stackoverflow.com/questions/4293333
复制相似问题