2012-09-06 24 views
1

页是目前可在下列地址mod_rewrite的增加中间层目录

http://www.domain.co.uk/solutions/page-name1 
http://www.domain.co.uk/solutions/page-name2 
http://www.domain.co.uk/solutions/page-name3 

所以,我想我想在站点根目录的.htaccess文件中使用mod_rewrite,在每个传入页面请求的解决方案目录后添加'article'目录。我一直在寻找一个合适的答案约一个月,我试着学习mod_rewrite基础教程,但我不能让这个工作对我很抱歉,因为另一个mod_rewrite问题。

这是我目前的.htaccess文件:

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # Removes index.php 
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 

    # If 404s, "No Input File" or every URL returns the same thing 
    # make it /index.php?/$1 above (add the question mark)  
</IfModule> 
+0

对于搜索引擎优化真的没有错//solutions/article/page-name3和一个人可以很容易地排序你的SEO网址10倍以上的URL像/?article_id = 9566非常好的页面内容+页面标题+良好的反向链接。 –

+0

谢谢,但我知道这一点。这些网页已经存在,并且在网上直播。一个新的网站(在一个新的平台上)是由一个网络开发者创建的,我正在尝试纠正这个网址,这样当它被投入使用时,我们不必实施过多的301重定向,这通常会对搜索引擎优化产生影响。 – oliver

回答

0

编辑:

试试这个:

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{REQUEST_URI} !^solutions/article/ 
RewriteRule ^solutions/(.*)$ /solutions/article/$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png)$ [NC] 
RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 
+0

感谢您的回复。我将它添加到我的mod_rewrite代码中,但它似乎没有任何影响。 – oliver

+0

你能解释更多你试过的网址吗? – Oussama

+0

错过'RewriteEngine On'也许? – AllInOne

1

我做对我的网站类似的东西。下面是我使用删除index.php文件并显示缩短的URL中的.htaccess规则:

RewriteEngine On 

# Removes index.php 
RewriteCond $1 !\.(css|js|gif|jpe?g|png|ico) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 

RewriteCond %{REQUEST_URI} ^/solutions/(.*) [NC] 
RewriteRule ^(.*) /solutions/article/%1 [L] 

请记住,您在浏览器的地址栏中显示的网址是不是ExpressionEngine看到URL - EE看到{segment_2 }作为“文章”。