Jump to content

change links using .htaccess


KhaledBawz

Recommended Posts

okay

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*)/$ $1 [R,L]
RewriteRule ^([a-zA-Z0-9_-]+)$ $1\.php [L,QSA]

Options +FollowSymLinks
RewriteRule profile-(.*)$ profile.php?username=$1					
								

now the links is: www.mysite.com/profile-abc

Hey @KhaledBawz,

 

not too much time today but when I ran your script I've got a fake result:

Array
(
    [username] => jazzman.php
)

But, userName is just jazzman, not jazzman.php, right?

 

Secondly, what about if you have inheritance in your files, so one URL goes to second then goes to third and so on?

 

Anyway, I am glad to see that you sorted out this issue.

 

Have a nice day,

 

jazz.

about the fake result I just fixed now, I didn't notice it last time

RewriteEngine On
 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^/?([a-z]+)$ $1.php [L]

Options +FollowSymLinks
RewriteRule profile-(.*)$ profile.php?username=$1					
								

all links is working fine, no any duplicated in path :) thank you jaz I appreciate your help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.