I want to use rewrite rule for may website.
I have a link
www.mysite.com/product.php?p_id=1212
Need to convert like
www.mysite.com/product/1212
Please suggest me the rewrite rule for .htaccess file.
Thanks in advance.
please add this rule in your .htaccess file
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^product/([0-9]+)/?$ product.php?p_id=$1 [NC,L]
Related
Following is my rewrite rule code written in the .htaccess file placed in the
beta1
folder.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /beta1/
RewriteRule /(.*) read.php?post=$1 [R,NC]
Currently the URL is:
http://localhost/beta1/read.php?post=Happy+Mother+Day.
And i want the link to appear like:
http://localhost/beta1/Happy-Mother-Day.
Do I also need to change the way "read.php" extracts data from the database? If yes, then how?
Do i also need to make any changes in the "read.php" file?
The rewrite code above is not working.
hey please try this rule
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^([A-Za-z0-9-_]+)?$ read.php?post=$1 [NC,L]
And read.php file
echo str_replace('-',' ', $_GET['post']);
I am using WAMP and my url is localhost/hotel/hotels.php?id=21
Using rewrite rule as follow,
Options +FollowSymLinks
RewriteEngine on
RewriteRule hotels/id/(.*)/ hotels.php?id=$1
RewriteRule hotels/id/(.*) hotels.php?id=$1
But nothing happens..
My mod_rewrite is on and also changes done in httpd.conf file.
Please give me a suggestion to handle the issue?
You must use flags for your RewriteRule. You can change it as follow
RewriteEngine on
RewriteRule ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L]
You can call your pages from
localhost/hotel/hotels/id/12
If your .htaccess file is located in localhost/hotel .
I want to rewrite the url in my project.
For example:
http://www.example.com/dashboard/test/ to http://dashboard.example.com/index.php
Also I want to do it for:
http://www.example.com/dashboard/test2/ to http://dashboard.example.com/index.php
Can anyone tell me the idea to rewrite the url?
First you create a .htaccess file in your root.
Than, just put the redirect commands in it.
How to compose a .htaccess and how to create rewrite rules is explained here: http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/
You will need something like:
RewriteRule ^(.*)$ http://dashboard.example.com/$1 [L,QSA]
try this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^test.*$ http://dashboard.example.com/index.php [R=301,L]
I am new to htaccess and want to do following thing,
I want to rewrite url like,
http://example.com/test/test.php to http://example.com/test.html
and my htaccess file present in test folder. Can anyone help to find out this problem.
Thank You
That should do it:
RewriteEngine on
RewriteRule ^(.*).html$ test/$1.php [QSA]
Please how can I rewrite
Could anybody please rewrite this url?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
to
http://localhost/display_news_cat/14/2
Thank you
You can do thtat with a .htaccess file
put this in a .htaccess file and place it in de root of your site
apache must have mod-rewrite on
RewriteEngine on
RewriteRule ^news.php news [QSA,L]
try this for all files
RewriteEngine on
RewriteRule ^(a-zA-Z0-9).php $1 [QSA,L]
Assuming you have installed the rewrite module, you could put this in your virtualhost:
RewriteEngine ON
RewriteRule /newsdev/news /newsdev/news.php [L]
Check this site for more information on RewriteRule:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
But I doubt this is the best way. The rewritemodule is usually not the most efficient way to do easy things like these. Depends on what other complex things you want to rewrite.
With mod_rewrite
http://www.easymodrewrite.com/example-extensions
You need to work with the .htaccess file in your site root... you'll have to create one if it's not there.