eMoneySpace
Welcome, Guest. Please login or register.
Did you miss your activation email?
News: Welcome to eMoneySpace! Dec 09, 2022 04:08 am




Mod_rewrite tutorial
Print
Author Topic: Mod_rewrite tutorial  (Read 1762 times)
Razze
Reputation: (+4)
*

Offline

Posts: 305
Referrals: 23


View Profile
Mar 24, 2009 01:41 pm

Options +FollowSymLinks
RewriteEngine On <-- activates rewrite
RewriteBase /


RewriteRule ^(.*)\.html index.php?view=$1 [L]
RewriteRule ^(.*)\.ref index.php?ref=$1 [L]

This is for auroa script

this will make

so pages instead of index.php?view=account or whatever

would be account.html = shorter url & more seo friendly

the .ref means, instead of index.php?ref=name it will be

url/name.ref

again seo friendly and more professional


« Last Edit: Mar 24, 2009 02:00 pm by Razze » Logged

link not working
Origin
Reputation: (+28)
*

Offline

Gender: Male
Posts: 2432
Referrals: 18


Super Noob!

View Profile WWW
Reply #1: Mar 24, 2009 01:55 pm

Forgot to put RewriteBase?
Logged


I accept coding work..
Razze
Reputation: (+4)
*

Offline

Posts: 305
Referrals: 23


View Profile
Reply #2: Mar 24, 2009 01:58 pm

What i know that isn't needed for simple rewrited url's o_O



edit:
adding it ...
Logged

link not working
Origin
Reputation: (+28)
*

Offline

Gender: Male
Posts: 2432
Referrals: 18


Super Noob!

View Profile WWW
Reply #3: Mar 24, 2009 03:08 pm

It's necessary if the script is installed not in the root.
Logged


I accept coding work..
Delusional

Reputation: (+2)
*

Offline

Gender: Male
Posts: 4713
Referrals: 6


GPSBlack Creator

View Profile WWW
Reply #4: Mar 24, 2009 05:08 pm

also allows spiders to steal ur content easier.

BTW There is a massive bug in mod_rewrite in current Apache releases: mod_rewrite strips one level of URL encoding between matched strings and output values. If your incoming URL happens to contain URL encoded values, it will thus generate invalid URLs. for example:

Code:
RewriteRule ^something/(.*) something.php?var=$1
If you pass in a URL like

Code:
something/hello%20world
It will be rewritten as:

Code:
something.php?var=hello world
which is not a valid URL.

It happens that this is bearable for many cases (also why it has not been fixed), as URL encoding does not affect many string values, but if you’re doing anything like passing entire URLs as parameters (e.g. for a redirector), this can cause major problems. This problem has nothing to do with the [NE] option, which is concerned with allowing URL encoded values in the rewrite rule itself, not the string it is applied to.
« Last Edit: Mar 24, 2009 05:16 pm by Delusional » Logged

Print
 
Jump to:  
Copyright © 2008-2022 eMoneySpace. All rights reserved.