Timeline for htaccess Redirect Using Regex
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 30, 2020 at 15:38 | vote | accept | kmm2908 | ||
Apr 30, 2020 at 10:53 | comment | added | kmm2908 | Redirect match did it for me! Many thanks! | |
Apr 30, 2020 at 10:29 | history | edited | MrWhite | CC BY-SA 4.0 |
Update to suggest using mod_alias RedirectMatch instead.
|
Apr 29, 2020 at 15:01 | comment | added | MrWhite |
Ah, in that case you need to modify the RewriteRule pattern to remove the namedeal/ subdirectory. I've updated my answer.
|
|
Apr 29, 2020 at 14:59 | history | edited | MrWhite | CC BY-SA 4.0 |
Update with respect to comments - the htaccess file is in a subdirectory!
|
Apr 29, 2020 at 14:47 | comment | added | kmm2908 | This htaccess is in the sub directory /namedeal/ | |
Apr 29, 2020 at 13:50 | comment | added | MrWhite |
Also, I'm assuming this .htaccess file is in the document root of your site?
|
|
Apr 29, 2020 at 13:38 | comment | added | MrWhite |
Assuming you have a RewriteEngine On directive, you may have a conflict with existing directives. Do you have other directives in your .htaccess file? Do you have any other .htaccess files in subdirectories? Please edit your question to include the contents of your .htaccess file.
|
|
Apr 29, 2020 at 13:01 | comment | added | kmm2908 | Ok still not working for me. RewriteRule ^namedeal/[a-z]{2}_domain_name\.php$ /namedeal/cheap_domain_name.php [R=301,L] #Redirect 301 /namedeal/ca_domain_name.php /namedeal/cheap_domain_name.php The commented out line below does work. The one with regex does not. Even if I point the regex version to redirect to the index page it still doesn't work. It just isn't detecting the url using the regex. Can anyone explain why? Thanks in advance again. | |
Apr 29, 2020 at 9:17 | comment | added | kmm2908 | Thank you. Working on this now. | |
Apr 28, 2020 at 11:57 | history | edited | MrWhite | CC BY-SA 4.0 |
Fixed typo and added note about the "{2}" quantifier.
|
Apr 28, 2020 at 11:48 | history | answered | MrWhite | CC BY-SA 4.0 |