How to rewrite these url on htaccess - php

i want to rewrite these URL
getimage.php?videoid=myquery
to
img/myquery
i try this ht access code but after this its show empty page
RewriteEngine On
RewriteBase /
RewriteRule ^img/(.+) getimage.php?videoid=$1
please tell me how to set it

You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /getimage.php\?videoid=([^\s&]+) [NC]
RewriteRule ^ img/%1? [R=302,L,NE]
RewriteRule ^img/([^/.]+)/?$ getimage.php?videoid=$1 [L,QSA,NC]

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} videoid=(.+)
#RewriteRule getimage.php$ /img/%1? [R=301,L] #redirect
RewriteRule getimage.php$ test/%1? [L] #rewrite

Related

htaccess rewrite url parameter

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]

Vanity URL not working

I am using htaccess to try and rewrite a url. I have tried about 10 versions of the code and examples but nothing makes any change. I know mod_rewrite is working because it is adding www to the url, but the vanity URL won't work.
RewriteRule ^franchise/([0-9]+)/?$ franchise-information.php?franchiseid=$1 [NC,L] # Handle product requests
Here is the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^franchise/([0-9]*?)/$ franchise-information.php?franchiseid=$1 [NC,L]
</IfModule>
And here is the URL:
http://www.playballkids.com/franchise-information.php?franchiseid=162
You can use this code in your DOCUMENT_ROOT/.htaccess file:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /franchise-information\.php\?franchiseid=([^\s&]+) [NC]
RewriteRule ^ franchise/%1? [R=302,L,NE]
RewriteRule ^franchise/(\d+)/?$ franchise-information.php?franchiseid=$1 [NC,L,QSA]

rewrite url www.xyz.com/index.php?id=xyz to www.xyz.com/xyz using htaccess

I want to include item details details.php if url has parameter id=xyz
rewrite
url www.example.com/index.php?id=xyz
to
www.example.com/xyz.html
using htaccess
htaccess i am using has
RewriteEngine On
RewriteBase /
RewriteRule ^([^.]+)\.html$ index.php?id=$1 [L,QSA,NC]
RewriteCond %{THE_REQUEST} \s/index\.php\?id=([_0-9a-zA-Z-]+)\s [NC]
RewriteRule ^%1? [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+)$ /index.php?id=$1 [L]
RewriteCond %{THE_REQUEST} \s/index\.php\?id=([_0-9a-zA-Z-]+)\s [NC]
RewriteRule ^ %1.html? [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+?)(?:\.html)?$ /index.php?id=$1 [NC,L]
worked perfect
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^([^.]+)\.html$ index.php?id=$1 [L,QSA,NC]
Use this .htaccess to rewrite:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)\.html$ index.php?id=$1 [L,QSA,NC]
</IfModule>
Make sure you have mod_rewrite enabled (use phpinfo() or apache_get_modules() in PHP if available)
Please try following configuration in your www.example.com/.htaccess file,
i just test it and work fun on my env.
//htaccess file content
RewriteEngine On
RewriteRule ^(\w+).html$ /index.php?id=$1 [L]

Need to rewrite URL in .htaccess?

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]

Simple htaccess redirection

I would like to create a redirection like this:
http://www.myserver.com/recipe/xxxxx.html?v1=blabla&fb_action_ids=bla&v3=blablabla
To
http://www.myserver.com/recipe/xxxx.html
Note: xxxx in the url is different according to the page.
htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^home.htm http://www.xxxxxxxxxx.co.uk/ [R=301,NC,L]
RewriteRule ^breads.htm http://www.xxxxxxxxxx.co.uk/whatwemake/ [R=301,NC,L]
RewriteRule ^cakes.htm http://www.xxxxxxxxxx.co.uk/patisserie/ [R=301,NC,L]
RewriteRule ^farmers_market.htm http://www.xxxxxxxxxx.co.uk/wheretobuy/ [R=301,NC,L]
RewriteRule ^about_us.htm http://www.xxxxxxxxxx.co.uk/ourstory/ [R=301,NC,L]
RewriteRule ^contacts.htm http://www.xxxxxxxxxx.co.uk/contact/ [R=301,NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(recipe/[^.]+\.html)\?fb_action_ids=[^\s]+ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(news/[^.]+\.html)\?fb_action_ids=[^\s]+ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(event/[^.]+\.html)\?fb_action_ids=[^\s]+ [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
SetEnv APPLICATION_ENV production
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+((?:news|event|recipe)/[^.]+\.html)\?fb_action_ids=[^\s]+ [NC]
RewriteRule ^ /%1? [R=302,L]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.
This thing is via GET method [?v1=blabla&v2=bla&v3=blablabla] use POST then
You need a simple rewrite rule
RewriteRule ^(.*).html(.*) $1.html

Categories