.htaccess rewrite for a simpleton - .htaccess

I can generally figure this kind of thing out on my own, but I'm totally lost on how to write a rewrite rule in .htaccess
my current url looks like:
index.php?p=page&v=2&i=2&pg=01
I'm trying to make the url look like this:
/vol2/iss2/pg01/
Any help greatly appreciated! Thanks!

Try something like following
RewriteEngine on
RewriteRule ^vol([0-9]+)/iss([0-9]+)/pg([0-9]+)/$ index.php?p=page&v=$1&i=$2&pg=$3

Related

Proper .htaccess redirect code

I need help to redirect old URL to new URL by using .htaccess.
I code my website by using CakePHP. Initially, I didn't change pagination URL structure. So my URL looking like this. This is just an example, actually it contain a lot more sub-directory & pages.
http://www.web.com/abc/
http://www.web.com/abc/page/page:2/
http://www.web.com/abc/page/page:3/
...
...
http://www.web.com/def/
http://www.web.com/def/page/page:2/
http://www.web.com/def/page/page:3/
...
...
http://www.web.com/ghi/
http://www.web.com/ghi/page/page:2/
http://www.web.com/ghi/page/page:3/
...
...
Many people say this is not good for SEO, so I change my URL structure to be like this. The coding is CakePHP is all done.
http://www.web.com/abc/
http://www.web.com/abc/page/2/
http://www.web.com/abc/page/3/
...
...
http://www.web.com/def/
http://www.web.com/def/page/2/
http://www.web.com/def/page/3/
...
...
http://www.web.com/ghi/
http://www.web.com/ghi/page/2/
http://www.web.com/ghi/page/3/
...
...
What I need to do next is to redirect my old URL to the new URL. I need help on the proper code which can redirect all my URL without doing it one by one.
Really appreciate any help on this. TQ
Well something like this should work
RewriteRule ^(.+)/page:([0-9]+)/$ /$1/$2/ [R=301,L]
RewriteEngine On
RewriteRule ^(.*)/page:([0-9]*)(.*)$ /$1/page/$2$3 [R=301,L]

Rewrite Rule to Create Directory Shortcut

I have a file that is located at:
http://www.mydomain.com/alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc
I would like to be able to access RemotingService.cfc like this:
http://www.mydomain.com/remoting/RemotingService.cfc
I have tried several different Rewrite rules but none are working correctly.
Can anyone point me in the right direction?
Thanks
Try adding this in the htaccess file in your document good
RewriteEngine On
RewriteRule ^/?remoting/RemotingService.cfc$ /alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc [L]

htaccess rewrite logout url

I have a url like this
http://example.com/wp-login.php?action=logout&_wpnonce=ab720d18d2
Can someone help me to rewrite like this
http://example.com/logout/ab720d18d2
Thanks
We are here to answer question. Not to write code for you.
But because it is almost christmas:
RewriteRule ^logout/(.*) /wp-login.php?action=logout&_wpnonce=$1

.htaccess RewriteRule help

I've been trying to create a rule.
If anyone could help, I would be extremely grateful.
Request: domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
Rewrite to: domain.com/c/wb/rs/rs/1tb/25n/ru/rs
Thanks in Advance
I think you have this a bit backwards. The idea behind URL rewriting is that you take a nice neat URL like this (what the user sees):
http://domain.com/c/wb/rs/rs/1tb/25n/ru/rs
and rewrite it behind the scenes into an uglier but PHP etc. friendlier URL like this (what the server processes):
http://domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
To do that, use this:
RewriteEngine On
RewriteRule ^/c/wb/(.*) http://domain.com/c/wb.php?p=$1 [L, NS]
It should look something like this
RewriteRule ^(c/wb)\.php\?p=(rs/rs/1tb/25n/ru/rs)$ $1/$2 [L,NS]
Still I'm not sure if you need slash in front of c/wb if you're using this in your .htaccess file. You need slash if you're using this in the VirtualHost configuration.

htaccess rewrite rules

I have a url structure like this:
\http://www.domain.com/virtual_tours/virtual_name/
\http://www.domain.com/virtual_tours/virtual_name/virtual_tour_name-001.php?format=something
\http://www.domain.com/virtual_tours/virtual_name/virtual_tour_name-002.php?format=something
and I need to map those to the new urls that will look like this:
\http://www.domain.com/virtual-tours/virtual-name.php
\http://www.domain.com/virtual-tours/virtual-name/virtual-tour-name-001.php
\http://www.domain.com/virtual-tours/virtual-name/virtual-tour-name-002.php
Can someone help me with the condition and rule for this?
I don't think that is good idea to perform something like str-replace inside .htaccess.
Much more better and flexible method is to rewrite all URL you need to the php script and perform the REQUEST_URI parsing and URL routing inside via PHP code.
RewriteEngine On
RedirectMatch permanent ^/(virtual_tours)/(virtual_name)$ http://www.domain.com/virtual-tours/virtual-name.php
RedirectMatch permanent ^/(virtual_tours)/(virtual_name)/virtual_tour_name-(.*)\?.*$ http://www.domain.com/virtual-tours/virtual-tour-name-$1.php

Resources