I have website. I just want to rewrite url using .htaccess
Here is the code which I want to rewrite:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} /search_data.php\?keywords=([^&]+)&f=([^\s&]+) [NC]
RewriteRule ^/search_data.php/?$ /search/%1/%2? [R=301,L,NC]
this the current url
http://localhost/mywbsite/search_data.php?keywords=one+piece&f=149
I want to convert this to this
http://localhost/mywbsite/search/one-piece/149
I tried above code but its not working please help me
QUERY_STRING is only used to match query string without URI.
You need to use:
Options -MultiViews
RewriteEngine On
RewriteBase /mywbsite/
RewriteCond %{THE_REQUEST} /search_data\.php\?keywords=([^&]+)&f=([^\s&]+) [NC]
RewriteRule ^ search/%1/%2? [R=301,L]
RewriteRule ^search/([^/]+)/([^/]+)/?$ search_data.php?keywords=$1&f=$2 [QSA,L,NC]
Related
Get:
https://xxx.ru/page/?page=update-1/
how to show:
https://xxx.ru/page/update-1/
I tried does not work
.htaccess
RewriteBase /
RewriteEngine on
RewriteRule ^page\/(.*?)/?$ page/?page=$1 [L,QSA]
You can use:
RewriteEngine on
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+page/\?page=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^page/(.+)$ page/?page=$1 [L,QSA,NC]
Use this:
RewriteEngine On
RewriteRule ^page/([^/]*)$ /page/?page=$1 [L]
It will give you the following URL:
https://xxx.ru/page/update-1/
I have url that I want to rewrite so it can pass the parameter like this
From www.example.com/questions.php/postid=101&title=htaccess_tuts
To www.example.com/questions.php/postid/1/title/htaccess_tuts
I have been trying to get this done using below .htaccess but i end up getting this
From www.example.com/questions.php/postid=1&title=htaccess_tuts
To www.example.com/questions.php/postid/101
The title part didn't show.
Can anyone help me pass it multiple parameter
RewriteBase /
#Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#here is the problem i have don this but didn't work
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+questions\.php\?postid=([^\s&]+)&([^\s&]+) [NC]
#What can i do again?
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+questions\.php\?postid=([^\s&]+) [NC]
RewriteRule ^ questions/%1? [R=301,L]
RewriteRule ^questions/([^/]+)/?$ questions.php?postid=$1&title=$2 [L,QSA]
RewriteEngine On
RewriteRule ^questions\.php/postid/([^/]*)/title/([^/]*)$ /questions.php?postid=$1&title=$2 [L]
you can use this site for generate rewrite rules
I want to redirect
http://localhost:8080/mypproject/?supplier=test123
to
http://localhost:8080/myproject/?product_cat=test123
But I don't know how...
You can use this code in your /myproject/.htaccess file:
RewriteEngine On
RewriteBase /myproject/
RewriteCond %{QUERY_STRING} ^supplier=([^&]+) [NC]
RewriteRule ^/?$ ?product_cat=%1 [L,R=301]
I want to rewrite my URL
From:
https://example.com/fr/transporter/transporterPublicProfile.php?profil=1927&token=xnbjfgh4534534534dgfsdsd4
To:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
When ever a user visit this URL:
https://example.com/fr/transporter/transporterPublicProfile.php?profil=1927&token=xnbjfgh4534534534dgfsdsd4
It should appear like this:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
And if a user visit this URL:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
Its should remain as it is.
What I have tried so far is:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /fr/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+) [NC]
RewriteRule ^ fr/profil-des-transporteurs/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^profil-des-transporteurs/([^/.]+)/?(.*)$ transporter/transporterPublicProfile.php?profil=$1&token=$2 [L,QSA,NC]
RewriteBase /
#RewriteRule ^/fr/shipper/(.*)$ https://example.com/fr/$1 [L,R=301]
#RewriteRule ^login.php https://example.com/fr/shipper/login.php [L]
RewriteRule ^index\.html /index\.php......................
The problem in above .htaccess is it works fine with one parameter i.e profil
. But when I get token in URL, it doesnt work.
What will be the correct .htaccess code for this scenario?
You need to have new set of rules for new parameter:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /fr/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+)&token=([^\s&]+) [NC]
RewriteRule ^ profil-des-transporteurs/%1/%2? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+) [NC]
RewriteRule ^ profil-des-transporteurs/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^profil-des-transporteurs/([^/.]+)/([^/]+)/?$ transporter/transporterPublicProfile.php?profil=$1&token=$2 [L,QSA,NC]
RewriteRule ^profil-des-transporteurs/([^/.]+)/?$ transporter/transporterPublicProfile.php?profil=$1 [L,QSA,NC]
RewriteRule ^index\.html /index\.php [L]
i need to rewrite the urls as below from your help.
i have this url for search
search-job.php?category=Accountancy&emp_type=Long+Term&working_pattern=Full+Time&location=Algeria&search=Search+Job
to
search-job-in-Accountancy-for-Full+Time-in-Algeria.html
OR from this
search-job.php?category=2&emp_type=2&working_pattern=2&location=12&search=Search+Job
To this
search-job-2-2-2-12.html
i have already done this
job-detail.php?j=Exalture-Software-Labs-Pvt-Ltd-Application-Developer-Websphere-Commerce-Suite-ais-GBS-in-India-Full-Time-Mumbai-11.html
To This
job-detail/Exalture-Software-Labs-Pvt-Ltd-Application-Developer-Websphere-Commerce-Suite-ais-GBS-in-India-Full-Time-Mumbai-11.html
My .htaccess is below
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /temp
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+job-detail\.php\?j=([^\s&]+) [NC]
RewriteRule ^ job-detail/%1? [R=301,L]
RewriteRule ^job-detail/([^/]+)/?$ job-detail.php?j=$1 [L,QSA]
Pls provide some help.
You need these additional rules:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search-job\.php\?category=([^&]*)&emp_type=([^&]*)&working_pattern=([^&]*)&location=([^&]*)&search=([^\s&]+) [NC]
RewriteRule ^ search-job-%1-%2-%3-%4? [R=301,L,NE]
RewriteRule ^search-job-([^-]*)-([^-]*)-([^-]*)-([^-]*) search-job.php?category=$1&emp_type=$2&working_pattern=$3&location=$4&search=Search+Job [L,QSA]