Posted by blueblade on September 5, 2009 at 11:55pm
Jump to:
| Project: | Path redirect |
| Version: | 6.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi,
I am using Content Profile, Views and Automatic Aliases.
I created a Views page and one of the link is supposed to link to the 'default' content profile page (users/[user id]) but instead the link is taking the users to node/[user id] page which look quite different from the 'default' profile page. I have used Automatic Aliases to change node/[user id] to profile/[user id]. Now I want to redirect all profile/[user id] pages to users/[user id]
My question here is, what should I use for [user id]? I have tried % and * but none works...what should go after # and ? on admin/build/path-redirect/add page?
Thanks for your help.
BB
Comments
#1
Adding your own rewrite rule in your site's .htaccess is the most guaranteed way. There is no support for wildcards in Path redirect, which is what you need.
#2
Thanks Dave,
I have no idea how to rewrite rule in .htacess...is there any reason why wildcards is not supported in Path redirect?
BB
#3
Because they can't be reliably done through Drupal and it's interface as well as .htaccess rewrite rules can be. There are tons of articles out there teaching how to write rewrite rules.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
I'm hoping there's a different way to do this. I would like to redirect /users/XX pages to the associated content profile page. But .htaccess wouldn't have access to the relationship between the /users/XX page and the content profile page (i.e. the UID of the owner of the content profile node is the same as the XX user ID).
Thoughts on that?
THANKS!
#6
I have just tried writing a RewriteRule without luck.
What I want to do is to redirect URL from:
user/[uid]
to
users/[uid]
and the RewriteRule I have is
RewriteRule ^user/([0-9]+)$ /users/ [R]
but it didnt work....it looks like this wont do anything to the "user" part at all...can someone please point out what is not done correctly?
Many thanks.
BB
#7
RewriteRule ^user/([0-9]+)$ /users/$1 [R,L]#8
Hi Dave Reid,
Thank you so much for your kind help again and again. That line works perfectly. You have a great one!!
BB
#9
Automatically closed -- issue fixed for 2 weeks with no activity.
#10
Hi David,
Sorry for asking so many times but I have just noticed that my RewriteRule has stopped working. I did install/update a few modules in the past months but I cant find which module is causing the problem by deactivate them. Can this be an apache issue instead? Thanks in advanced for your help. Also, I will try to downgrade to Drupal 6.15 tomorrow to see if this is caused by Drupal 6.16.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^user/([0-9]+)$ /users/$1 [R,L]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
#11
I have just uninstalled the Views-6.x-2.10 and RewriteRule ^user/([0-9]+)$ /users/$1 [R,L] is working again. will post this on Views issues page.