I have two URLs pointing to the same directory, let's call them www.english.com and www.french.com. My htaccess file has a redirect as follows:
Redirect 301 /one http://www.english.com/#/one
If someone goes to www.english/one they are taken to the revised URL above, but the french URL also redirects to the English. Is there a way to have an if statement of kinds to direct www.french.com/one to www.french.com/#/one while keeping the English redirect in order?
Any help is greatly appreciated
Not with Redirect. But it is possible using mod_rewrite.
RewriteEngine On
RewriteBase /
RewriteRule ^one$ /#/one [R,L,NE]
Related
i´m trying to do a 301 redirect in my .htaccess with the following lines:
Options +FollowSymLinks
RewriteEngine On
Redirect 301 /oldpage http://www.myhomepage.de/newpage/
The problem is, that the redirected url looks like this:
http://www.myhomepage.de/newpage/?it=oldpage
and that naturally causes a 404 on my site.
Does anybody know, what the problem could be?
Thanks a bunch!
This should work for you:
RewriteRule ^oldpage$ newpage? [R=301,L]
The question mark at the end of the destination will tell it to use a blank query string.
The above assume the pages are on the same domain. But if you're moving to another domain, this should do the trick:
RewriteRule ^oldpage$ http://newdomain.tld/newpage? [R=301,L]
I find a lot of answers to this question (and I have read dozens of them), but they are all about more advanced stuff with patterns and such stuff.
I just need a very simple and basic redirect for static urls.
If I add a trailing slash to the url, the redirect doesn't work and I just can't figure out why.
Example:
RewriteEngine On
Redirect 301 /content https://www.example.com/site/content.html
Redirect 301 /content/ https://www.example.com/site/content.html
https://example.com/content does work, https://example.com/content/ redirects to https://example.com/site/
What is the problem here?
Don't mix mid_rewrite rules with Redirect (mod_alias). Use this rule as very first rule in your root .htaccess:
RewriteEngine On
RewriteRule ^content/?$ https://www.example.com/site/content.html [L,NC,R=302]
I am doing a set of 301 redirects in Drupal.
I am using a standard method in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
</IfModule>
but the return url ends up with "?q=user" and stops it working. eg:
http://thesitedomain.com/about?q=user/about
I am not great at htaccess redirects (obviously) and I am no Drupal expert at all.
Also, if you know of a comprehensive htaccess rewrite resource I would much appreciate reading hat.
You will need to use mod_rewrite instead to strip out existing query string:
RewriteEngine On
RewriteRule ^user/testimonials/?$ http://thesitedomain.com/testimonials? [L,NC,R=301]
RewriteRule ^user/contact/?$ http://thesitedomain.com/contact? [L,NC,R=301]
Take note of trailing ? in target that strips out existing query string.
I can't speak to drupal, but I know you don't need to enclose those redirects in the <IfModule mod_rewrite.c> tags, since they don't use the RewriteEngine, the below would suffice:
Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
Are both urls in the same drupal? Or are you moving from a different site?
I mean:
/user/testimonials
http://thesitedomain.com/testimonials
Maybe what you need is to add an url alias for /user/testimonials like /testimonials
See under admin at /admin/config/search/path in drupal 7.
Using .htaccess file is not a good practice, because, in some updates you have to update the .htaccess file too.
You can try GlobalRedirect module to manage your redirects.
I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.
Basically I need to redirect this:
/example/my-stuff/
to:
/example/home/
but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.
/example/my-stuff/a-page
/example/my-stuff/anything
In the htaccess file in your document root, you can add either this:
RedirectMatch 301 ^/example/my-stuff/$ /example/home/
Or you can use mod_rewrite instead:
RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]
Well, I have website with such structure of pages:
domain.com/group-1/page/ and now I need to make htaccess 301 redirect to
domain.com/group-1/{constant}-page/
where {constant} any fixed word (plus minus sign). This rule should not effect any other groups, except group-1
Thank You.
This can be done with mod_rewrite. Put this .htaccess code into the domain's root directory.
RewriteEngine On
RewriteRule ^group-1/page/(.*)$ group-1/constant-page/$1 [L,R=301]