4

I've been trying to to find a solution using .htaccess to redirect the following urls:

from:

mydomain.com/my-short-list/1AXC7682 or mydomain.com/my-short-list/1AXC7682/

to:

mydomain.com/my-short-list/?u=1AXC7682

from:

mydomain.com/user-reviews/42 or mydomain.com/user-reviews/42/

to:

mydomain.com/user-reviews/?urid=42 

and finally:

from:

mydomain.com/videos/1055687406001/130433/bmw-i8-concept-sports-car-in-detail or  
mydomain.com/videos/1055687406001/130433/bmw-i8-concept-sports-car-in-detail/

to:

mydomain.com/videos/?vid=1055687406001&pid=130433&url=bmw-i8-concept-sports-car-in-detail

Thank you!

0

2 Answers 2

5

Update your .htaccess with this code:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^my\-short\-list/([0-9]{1}[a-z0-9]{7})/?$ /my-short-list/?u=$1 [NC,L]
RewriteRule ^user\-reviews/([0-9]+)/?$ /user-reviews/?urid=$1 [NC,L]
RewriteRule ^videos/([0-9]+)/([0-9]+)/([a-z0-9\-]+) /videos/?vid=$1&pid=$2&url=$3 [NC,L]

#wp default
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
Sign up to request clarification or add additional context in comments.

20 Comments

Thank you for your reply, but unfortunately, it still not working, please see the comment on Tom Knapen post.
I see, yes code with wordpress will be different than using this code by itself in the .htaccess file
These redirections rules are driving me crazy man... Your solution made a lot of sense for me, but it still no working!
if you remove temporary the wordpress one does it work? (RewriteRule ^index\.php$ - [L] and after)- just comment then like add the #` before like: #RewriteRule ^index\.php$ - [L]
huh... that's interesting... it did work at all... in fact, the whole website went 404!
|
0

Try something like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^my-short-list/ my-short-list/?u= [NC,L]
RewriteRule ^user-reviews/ user-reviews/?urid= [NC,L]
RewriteRule ^videos/([0-9]+)/([0-9]+)/(.*)$ videos/?vid=$1&pid=$2&url=$3 [NC,L]

1 Comment

Sorry man,I should be more specific: I am using wordpress in my blog, and the current settings for .htaccess is: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress I've tried to use your and Book Of Zeus solution, but unfortunately, it still not working...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.