I am basically just trying to write a .htaccess redirect that turns the url
www.example.com/Artist/Profile?Artist='test' to www.example.com/Artist/test
without actualy redirecting the user.
use the following directive
RewriteCond %{QUERY_STRING} (^|&)artist='([^&]+)' [NC]
RewriteRule ^Artist/Profile$ /Artist/%2? [L,NC]
Related
i am having url like
mydomain.com/?q=ayx
i want to redirect it to straight
mydomain.com/ayx
currently using Backdrop cms , enable the clean url feature, tried to do with url redirect but didn't succeed.
I have tried the htaccess file changes as shown below, but this also not worked.
Please tell me what i doing wrong?
checked the mod_rewrite that is also enabled.
Thanks
RewriteCond %{THE_REQUEST} /\?q=ayz [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}/ayz? [L,R]
You may try this rule:
RewriteCond %{THE_REQUEST} /\?q=([^&\s]+)\s [NC]
RewriteRule ^ /%1? [L,R]
I'm trying to create a URL redirect but so far everything I have tried just hasn't shown any effect on the site. I know ModRewrite is enabled as there are other rewrites taking place. The whole purpose of this is to handle old URLs from the former version of the website.
What I want to achieve is a redirect of a URL with the following format:
/resources/view?id={id} and redirect it to /resources/{id}.
I've been trying to do so with variants of this:
RewriteRule ^resources/view?id=([0-9+])$ /resources/$1 [R=301,L]
and also this:
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^/resources/view$ /resources/$1? [R=301,L]
Cheers.
You can use these 2 rules in your site root .htaccess:
Options -MultiViews
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /resources/view\?id=(\d+) [NC]
RewriteRule ^ /resources/%1? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^resources/(\d+)/?$ resources/view?id=$1 [L,QSA,NC]
I have the following example urls that i need redirecting to www.example.co.uk
http://www.example.co.uk/wordpress/?feed=comments-rss2
http://www.example.co.uk/wordpress/?feed=rss2
http://www.example.co.uk/wordpress/?cat=518
http://www.example.co.uk/wordpress/?cat=514
http://www.example.co.uk/wordpress/?cat=520
http://www.example.co.uk/wordpress/?cat=521
http://www.example.co.uk/wordpress/?cat=523
http://www.example.co.uk/wordpress/?cat=515
http://www.example.co.uk/wordpress/?p=119
There are many more urls further to this list that all have a wordpress/ notation.
Would I have to write a conditional rewrite for each like this:
RewriteCond %{QUERY_STRING} ^feed=comments-rss2$
RewriteRule ^/wordpress/?(.*)$ http://www.example.co.uk [R=301,L]
RewriteCond %{QUERY_STRING} ^cat=518$
RewriteRule ^/wordpress/?(.*)$ http://www.example.co.uk [R=301,L]
or is there a rule i can write that redirect all urls that have /wordpress in them to redirect to www.example.co.uk
I believe a single rule like would be suffice:
RewriteCond %{QUERY_STRING} (^|&)(feed|p|cat)=[^&]+ [NC]
RewriteRule ^wordpress(/.*)?$ http://www.example.co.uk/? [R=301,L,NC]
Make sure this is very first rule in your .htaccess just below RewriteEngine On line.
I have a site that has a bunch of URLs indexed in Google that look like this -
http://www.domain-namr.com/?option=filter&option2=&option3=
I am trying to redirect all of these to a new URL in HTACCESS with this code -
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^option=filter$
RewriteRule ^(.*)$ /new-url.html [R=301,L]
Of course it is not working. On all of the pages that have a filename I can use in the request uri condition, the redirects work. What am I missing?
It is not working due to the wrong regex pattern in your rule.
Try this rule as your very first rule in root .htaccess:
RewriteCond %{QUERY_STRING} ^option=filter(&|$) [NC]
RewriteRule ^$ /new-url.html? [R=301,L]
I have a tricky issue redirecting some URLs internally for my site.
The situation is this, I currently have a URL like example.com/check/youtube.com which internally redirects to check.php?domain=youtube.com using the following mod_rewrite code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
RewriteRule ^offline offline.php [NC,L]
RewriteRule ^error error.php [NC,L]
RewriteRule ^check/(.*)$ check.php?domain=$1 [NC,L]
However I would also like to be able to redirect to check.php using a URL like example.com/youtube.com. Unfortunately it is just beyond me to figure it out.
I have a directory /assets/ with all the CSS, JS, etc. which shouldn't be affected.
Thanks
Try this rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/.]+\.[^/]+$ check.php?domain=$0 [L]
This rule rewrites any request with a URL path of the form [^/.]+\.[^/]+ (a string that contains at least one dot but no slashes at all) that cannot be mapped to an existing file to your check.php.
As you want to redirect "example.com/youtube.com" does that mean you wish to redirect pretty much anything? What is specifically allowed to be passed, e.g. would I be allowed to pass "example.com/youtube.com/foobar.php" for a redirect to check.php?