How to rewrite part of url in htaccess? - .htaccess

My url looks like
http://example.com/picture.php/82-1/category/19-appenzell_ausserrhoden?map
I want this to be re-written as
http://example.com/picture/82-1/category/19-appenzell_ausserrhoden?map
How can I do it in HTaccess?

I think this will work:
RewriteRule ^picture/?$ picture.php [NC,L] #flags: case insensitive, last

You can use this rule:
Options -MultiViews
RewriteEngine On
RewriteRule ^picture/(.+)$ picture.php/$1 [NC,L]

Related

.htaccess: Replace part of url for a domain

I have this url
www.mydomain.com/aftomelanomenes-sfragides/eos-7-grammes/197430-092399532491-sfragida-trodat-printy-4915-aytomelanomeni-mple-detail
and I would like to replace it with this
www.mydomain.com/aftomelanomenes-sfragides/eos-7-grammes/197430-092399532491-sfragida-trodat-printy-4915-aftomelanomeni-mple-detail
i tried this code to htaccess
RewriteRule ^-aftomelanomeni-?$ -aytomelanomeni-$1 [NC,L]
But it doesn't work
Try to use this pattern:
RewriteRule ^(.+)-aytomelanomeni-(.+)$ http://%{HTTP_HOST}/$1-aftomelanomeni-$2 [R=301,L]

Rewrite this URL htaccess

How i can proceed for rewrite this url
http://mywebsite.local/videos?c=mycat
to
http://mywebsite.local/videos-mycat
Thx
RewriteRule ^videos-mycat/?$ videos?c=mycat [NC,L]
maybe...
This is what you're looking for
RewriteEngine On
RewriteRule ^videos-([^/]*)$ /videos?c=$1 [L]

htaccess friendly urls 3 parameters

I've got an address like this:
/?pid=74&sid=381:naprawairegeneracjaturbosprezarek24hjozefkrezolek
and i want to have:
/74:381:naprawairegeneracjaturbosprezarek24hjozefkrezolek
or better:
/naprawairegeneracjaturbosprezarek24hjozefkrezolek
my .htaccess
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z]+):([a-z]+):([a-z]+)$ /index.php?pid=$1&sid=$2:$3 [L]
I have also rewrite rule to delete index.php from url
RewriteRule ^([0-9]+):([0-9]+):([a-z]+)$ /index.php?pid=$1&sid=$2:$3 [L]
You cannot achieve /naprawairegeneracjaturbosprezarek24hjozefkrezolek unless you make sure that index.php can find the correct item with only that parameter.

Htaccess redirect url with raw php url containing variables

I'm currently using a CMS that rewrites all URLs and currently I have a URL like this:
http://www.domain.com/folder/?user=user1
I'm looking to have that rewrite to: index.php?r=search&term=$1
Would something like this work?
RewriteRule ^/?user=(.*) index.php?r=search&term=$1 [L]
Seems to be giving me trouble. Any suggestions?
The query string is not part of the URI-path test it in the rule. It is at QUERY_STRING variable.
You may try this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} user=([^/]+)/? [NC]
RewriteRule ^folder/? /index.php?r=search&term=%1 [L,NC]
try ( not tested)
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^folder1/?user=(.*)$ index.php?r=search&term=$1 [R=301,L]

URL rewriting using htaccess

How to rewrite the url in htaccess
www.mywebsite.com/category.php?name="richard" change to www.mywebsite.com/richard/
You can use below code to achieve your requirement.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} name=(.*)
RewriteRule category\.php$ /%1/
Hope this helps you... :)
Are you used any PHP frameworks(like the codenigter... etc)?
You can try this:
RewriteRule ^(.*)$ /category.php/name=$1 [L]

Resources