I am Creating Rewrite Rule in .htaccess
I have some issue i am creating Rule like wordpress but i didnt get correctly
The Rule which i am writing is below
`RewriteRule projectDir/(.*)/(.*)/(.*)$ index.php?module=$1&action=$2&id=$3`
In this ReFacta is my Project Directory
The Url Which i want it same as like below
`http://localhost/projectDir/user/edit/5`
Any idea Friends ?
You are nearly correct. what is wrong in your code, you don't have specified RewriteBase
Options +FollowSymLinks
RewriteEngine on
RewriteBase /projectDir
RewriteRule ^(.*)/(.*)/(.*)$ /index.php?module=$1&action=$2&id=$3 [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 .
Looking to re write a url in WAMP. I have AllowOverride Al (conf file). The mod rewrite modules is loaded. I am working on localhost
What i want to acheive is that on login the user gets redirected
localhost/propcms/xxxxxxx/
the actual address is
localhost/propcms/status.php?id=xxxxxxx
the .htaccess file has the following (and is located in localhost/propcms/ )
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^propcms/([^/]*)/$ /propcms/status.php?id=$1 [L]
this is what i get....The requested URL /propcms/test121/ was not found on this server.
any ideas ??
Since you are specifying a rewritebase, you should not include it in your rewrite rule:
Try this snippet :
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^([^/]*)/$ /propcms/status.php?id=$1 [L]
My website has main domain & subdomains which has htaccess rewrite issue,
my issue is, there is htaccess code under www.example.com,
RewriteBase /
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^?]*).html$ content.php?pid=$1
When i create content page with url path www.example.com/test.html or www.example.com/folder/test.html it works absolutely fine.
But i have same code on my subdomain & the 'folder' url doesn't work. I mean subdomain.example.com/test.html works fine but subdomain.example.com/folder/test.html doesn't seem to work.
Thanks a lot in advance.. :) Please help...
Can you try this code in your subdomain .htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /subdomain/
RewriteRule ^([^.]+)\.html$ subdomaincontent.php?pid=$1 [L,NC,QSA]
Make sure there is no other .htaccess below subdomain.
For URL Rewriting, i have got the output for static URL
But , for dynamic URL , i am getting partial output only.
I have placed the .htaccess file in the root directory only.
Here is the code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/price/([0-9]+)/?$ booking.php?price=$1
What will be the solution ?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/([0-9]+)/?$ booking.php?price=$1
RewriteRule ^booking/([0-9]+)/([0-9]+)/?$ booking.php?price=$1&pass=$2
You really want to customise your code for these though so as to be able to use general rules, rather than converting specific paths to use $_GET.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/([0-9]+)/?$ booking.php?price=$1
RewriteRule ^booking/([0-9]+)/([0-9]+)/?$ booking.php?price=$1&pass=$2
For images and Css you need to define your base folder in htaccess file as
RewriteBase /~your folder/