Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: htaccess redirect after rewrite rule |
|
Author |
|
tdkappa
Joined: 15 Feb 2017 Posts: 8
|
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Mon 06 Aug '18 15:33 Post subject: |
|
|
Hello,
please don't mix mod_alias (for Redirect) and mod_rewrite (for RewriteRule ...) as mod_rewrite is processed before the mod_alias. See http://web.archive.org/web/20131107001958/http://my.opera.com/GreyWyvern/blog/2007/09/12/apache-mod-rewrite - paragraph "Order of Execution"
So the best way would be (as mentioned in the provided link) to not use mod_alias and replace these rules by mod_rewrite-rules and place the static-redirect-urls-to-other-urls-rules with the flag "L" before the already existing RewriteRule in your .htaccess.
So you may try to use this code as example/base for further engineering?
Code: | RewriteEngine On
RewriteRule ^/200/title-of-post-with-id-200 /100/title-of-my-post-with-id-100 [R=301,L]
RewriteRule ^/201/title-of-post-with-id-201 /158/title-of-my-post-with-id-158 [R=301,L]
RewriteRule ^([0-9]+)/([a-zA-Z0-9-]+)/$ /?p=$1 [L] |
|
|
Back to top |
|
tdkappa
Joined: 15 Feb 2017 Posts: 8
|
Posted: Tue 07 Aug '18 9:43 Post subject: |
|
|
hello mraddi
I try with Your example, but RewriteRule for the static address doesn't work
I see the content of the original address
For example:
Code: |
RewriteRule ^/200/title-of-post-with-id-200 /100/title-of-my-post-with-id-100 [R=301,L]
|
I see the content of ../200/title-of-post-with-id-200/ |
|
Back to top |
|
tdkappa
Joined: 15 Feb 2017 Posts: 8
|
Posted: Tue 07 Aug '18 9:50 Post subject: |
|
|
Ok, now it works !!
there is a problem with the final slash in the url !!
the correct Rewrite is:
Code: |
RewriteRule ^/200/title-of-post-with-id-200/ /100/title-of-my-post-with-id-100/ [R=301,L] |
Thank You a lot !! |
|
Back to top |
|
|
|
|
|
|