RedirectPermanent /forum-old-f48.html /forum-neu-f1.html
301 Result:
forum-neu-f1.html?f=48&start=
Target: Dont append the "?f=48&start=" part. How can I make a stop behind the html?
The result should look like this:
forum-neu-f1.html
thank you!
To strip off query string you need to use mod_rewrite rule. Have this rule in root .htaccess:
RewriteEngine On
RewriteRule ^forum-old-f48\.html$ /forum-neu-f1.html? [L,NC,R=301]
You should test it after clearing your browser cache.
Related
I want to replace this URL:
mydomain.com/posts/1659-artigos/etc-to
By this one:
mydomain.com/etc-to
Using .htaccess I'm trying the following:
RewriteEngine on
RewriteRule ^posts/1659-artigos/(.*)$ $1
But it isn't working. No redirect happens.
Can anyone help?
Thanks!
Converting my comment to answer so that solution is easy to find for future visitors.
You can use this code to get redirect working:
RewriteEngine on
RewriteRule ^posts/1659-artigos/(.*)$ /$1 [L,R=301,NC]
You need to use / before $1 for external redirect and make sure to use R flag for full redirect.
Going to show my lack of regex knowledge here but seem to be having trouble with the following:
I need to redirect the following example structure of a url:
www.example.com/blog-title-here/tags/this+is+a+long+tag+name
www.example.com/tag/this-is-a-long-tag-name
I need to redirect to just /tag and replace any instance of + with a -
You can use this recursive redirect rule as your very first rule in site root .htaccess:
RewriteEngine On
RewriteRule "(?:.*/)?(tag/[^ +]*)[ +]+([^ +]*[ +].*)$" $1-$2 [N,NC,DPI]
RewriteRule "(?:.*/)?(tag/[^ +]*)[ +]+([^ +]*)$" /$1-$2 [L,R=301,NC,NE]
This will redirect http://localhost/blog-title-here/tag/this+is+a+long+tag+name to http://localhost/tag/this-is-a-long-tag-name
As part of a migration I need to redirect sections of a site.
The below RedirectMatch is working, but the query string is being carried across.
I have tried using a "?" in various ways to remove the original query string, but have been unable to get it to work.
Current RedirectMatch:
RedirectMatch 301 ^/store/match.*$ http://shop.domain.com/new-directory/
The above RedirectMatch turns this:
domain.com/store/match-something-something-c-536.html?osCsid=123456…
Into this:
shop.domain.com/new-directory/?cPath=536&osCsid=123456...
But I want:
shop.domain.com/new-directory/
You need to use mod_rewrite for this:
RewriteEngine On
RewriteRule ^store/match http://shop.domain.com/new-directory/? [R=301,L,NC]
I add the code:
RedirectMatch 301 /san-pham/khuyen-mai/ /khuyen-mai
In default .htaccess file in opencart but the result will return:
http://myphamthiennhien.com/khuyen-mai?_route_=san-pham/khuyen-mai
You can test it here
http://myphamthiennhien.com/san-pham/khuyen-mai/
How can I solve it?
Use mod_rewrite to strip off query-string:
RewriteEngine On
RewriteRule ^san-pham/khuyen-mai/ /khuyen-mai? [L,R=301,NC]
Note ? in the end, that is required to strip query string.
My goal is simply to redirect:
/jsn.php?parameters to http://www.site2.com/jsn.php?parameters
I tried with
Redirect permanent /jsn.php(.)* http://www.site2.com/jsn.php$1
Query string parameters are automatically passed, you simply want to do this:
Redirect permanent /jsn.php http://www.site2.com/jsn.php
The (.)* doesn't work with the Redirect directive, you were probably thinking of RedirectMatch, but either way, you don't need it. And also (.)* should be (.*), otherwise the $1 backreference would only get the first character.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(jsn\.php)$ http://www.site2.com/$1 [L,NC,R=301]
You can use an explicit URL rewrite in your .htaccess file:
RewriteRule ^/jsn\.php\?(.*) http://www.site2.com/jsn.php?$1 [R]
Note: You need to escape . and ? because they are also regular expression characters.
If you have a problem using mod_rewrite, post the contents of your file.