Viewed   82 times

I wanna turn PHP dynamic URLs into static URLs. For example, I want URLs like

http://www.example.com/book.php?title=twilight to become http://www.example.com/book/twilight

and http://www.example.com/writer.php?name=meyers to become http://www.example.com/writer/meyers

When it's done, will my form validation on the site change?

My URL rewriting needs might not be much too complicated.

I'm developing it locally using XAMPP, Apache and MySql. Later I'll put it online.

How do I do that? Is this kind of URL rewriting technique the most adviced for SEO?

 Answers

5

Yep. U need to use mod_rewrite. Also do a search for .ht_access files. You can put your rewrite directives in .ht_access files and drop them in to whatever directory on your server where you want them to take effect.

For the type of rewrite you want this rule generator should be of use to you:

http://www.generateit.net/mod-rewrite/

And yes the URL you're trying to achieve is seo friendly.

Tuesday, October 11, 2022
 
muers
 
5

Create .htaccess file in your web root and enter following there:

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^product/([0-9]+)$ product.php?id=$1
Friday, September 16, 2022
 
3

If your server is Apache: Create on root folder file ".htaccess"

#.htaccess    
RewriteEngine On
Options +FollowSymlinks
RewriteRule /register index.php?mode=register

//index.php

<?php
if(isset($_GET['mode']=='register')){
      include('includes/register.php');
} 
?>
Monday, November 28, 2022
 
dakota
 
2

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 /

RewriteRule ^portfolio/(.*)$ /$1 [L,R=301,NC]
Sunday, October 23, 2022
 
ybs
 
ybs
4

in htaccess file insert this code :

RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]

The rewritten URL:

http://mysite.com/admin/List/User

this site very useful for generate rewrite URL

http://www.generateit.net/mod-rewrite/

Sunday, August 21, 2022
 
zb22
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :