I am trying to make SEO friendly website using php...
In folder jcheck i have a index.php file which take one parameter "id" as input.
mydomain.com/jcheck/index.php?id=1 works
How can i make it as follow
mydomain.com/jcheck/1
I have tried making .htaccess file and putting
RewriteEngine on
RewriteCond %{REQUEST_URI} 1/
RewriteRule 1/ http://mydomain.com/jcheck/index.php?id=1
How can i make it work?
You can essentially do this 2 ways:
The .htaccess route with mod_rewrite
Add a file called .htaccess in your root folder, and add something like this:
This will tell Apache to enable mod_rewrite for this folder, and if it gets asked a URL matching the regular expression it rewrites it internally to what you want, without the end user seeing it. Easy, but inflexible, so if you need more power:
The PHP route
Put the following in your .htaccess instead:
This will tell it to run your index.php for all files it cannot normally find in your site. In there you can then for example:
This is how big sites and CMS-systems do it, because it allows far more flexibility in parsing URLs, config and database dependent URLs etc. For sporadic usage the hardcoded rewrite rules in .htaccess will do fine though.
*****Copy this content from URL rewriting with PHP**
Put .htaccess file inside
jcheck
folder and write:and see also here it will usefull for you
Try this one:
In the htaccess file in your jcheck directory, use these rules: