Possible Duplicate:
Removing .php extension in URLs
I've changed the sub-directory of my public_html
to act as the main-directory.
Currently, mysite.com/alpha/index.php
redirects as mysite.com
. This is working perfectly.
Similarly, I have another file events.php
, i.e., mysite.com/alpha/events.php?eventid=10
corresponds to mysite.com/events.php?eventid=10
But, I wanted to access the above path as mysite.com/events/10/
instead of mysite.com/events.php?eventid=10
. For this I again modified the file, but it fails to load the dynamic URLs
.
For example, when I hover my mouse on links, it shows
`mysite.com/events/14`
`mysite.com/events/15`
`mysite.com/events/16`
`mysite.com/events/17`
etc. [which is what I want]
But on clicking it [If I click on the link that showed mysite.com/events/14
on hover], it opens a page mydomain.com//alpha/events.php/14/14?eventid=
and page fetches nothing from the sql
tables.
My .htaccess file:
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
RewriteRule ^([A-Za-z0-9\-]+)/([0-9]+)/?$ $1.php?eventid=$3
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/alpha/
# Don't change these line.'
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /alpha/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ alpha/index.php [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]