开发者

Drupal 7: redirecting non-/ urls to / for google pr purpose. "trailing slash" at the end of urls

开发者 https://www.devze.com 2023-02-18 23:15 出处:网络
I\'m working on a Drupal 7 site. it is a redesign from Codeigniter and the client wants to keep same urls for not to loose his Google PageRank. so I defined custom urls for pages at page-edit pages. T

I'm working on a Drupal 7 site. it is a redesign from Codeigniter and the client wants to keep same urls for not to loose his Google PageRank. so I defined custom urls for pages at page-edit pages. The problem is, client wants the urls with "trailing slash" at the end of urls.

how can I redirect all non-/ urls to / for Drupal 7?

for example the url is http://www.example.com/aboutus

and I need it to be http://www.example.com/aboutus/

I can't add this slash in custom path input at page editig form since Drupal says "do not use trailing slash"

and I have many urls like this, and most of them dynamically generated urls. so maybe some .htaccess trick?

Thanks a lot! appreciate helps!!!


UPDATE 1 for u开发者_StackOverflowseful info about "using trailing slashs" http://www.alistapart.com/articles/slashforward/


UPDATE 2

I tired the code below, but not working :/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)([^/])$ http://www.example.com/$1$2/ [R=301,L]

UPDATE 3

I have some particular urls that I need to redirect until I sort out this redirecting all urls issue. So I wrote the code below to htaccess

redirect 301 "/aboutus"  http://www.example.com/aboutus/

and it redirects to http://www.example.com/aboutus///////////////////// and it boviously doesn't work. What am I missing!?


++++++++++++ SORTED ++++++++++++

place the code to the top of .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]


++++++++++++ SORTED ++++++++++++

place the code to the top of .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
0

精彩评论

暂无评论...
验证码 换一张
取 消