URL rewriting help needed.

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
usalabs
-


Joined: 14 Nov 2005
Posts: 18

PostPosted: Fri Sep 14, 2007 11:21 pm    Post subject: URL rewriting help needed. Reply with quote

what would I need to put into the exact settings of X1 to rewrite this:-
Code:
http://www.mydomain.com/index.php?q=admin/settings/clean-urls

So that the question mark is not shown on all URL's that have the question mark, in it's URL.

I've read the tutorials, but I can't make head or tail of them, so I'm looking for some to explain in step-by-step instruction on what to put into each of the X1 URL rewrite settings.
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sun Sep 16, 2007 5:56 pm    Post subject: Reply with quote

Yes, the purpose of URL rewriting is to remove the ugly query string (which begins at the question mark in a URL).

First of all, do you have a scheme that your URLs will fit into?

For example, you have products to list.
Old URLs: /products.php?id=57
Desired URLs: /product/57

Or are you doing URL rewriting on a per-URL basis?
For example: /contact/contact.php --> /contact
/about_me.php --> /about
/blog/index.php --> /blog

------
If you're doing a per-URL basis for rewriting:
virtual path regex: ^/contact$
(the caret means "begins with" and the dollar sign means "ends with")
case sensitive: depends, but I usually uncheck this
conditions: don't need any, but if you need a complex solution, check this out
apply to sub-requests: you'd only need this checked if you're doing complex rewriting
if the rule matches: perform an internal redirection
redirect to: /contact/contact.php
append query string: yes
escape redirection location: yes
next action: stop matching
So, the browser asks for /contact, and the server sends out /contact/contact.php. Simple.
-------
If you have a scheme, you'll need some regex knowledge. Check out http://regular-expressions.info
For the products example:
virtual path regular expression: ^/products/([0-9]+)$
case sensitive: unchecked
conditions: none
apply to sub-requests: can be unchecked
if the rule matches: internal redirection
redirect to: /products.php?id=$1
(the $1 is a backreference - this variable holds the information matched in the first and only set of parentheses from the regular expression in the virtual path)
next action: stop matching
So, the browser asks for /product/57 and the server sends them /product.php?id=57

Mke sense?
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
usalabs
-


Joined: 14 Nov 2005
Posts: 18

PostPosted: Tue Sep 18, 2007 9:06 am    Post subject: Reply with quote

each of the query strings '?' has a line of different code after the ?

Because there'll be to many to individually rewrite every query string, all I'm looking for is a rewrite to remove the ? on all query strings in the url

For example. this url:-
Code:
http://www.mydomain.com/index.php?q=admin/settings/clean-urls

opens part of an admin section of a CMS site, each click on a link in the admin area has a different string after the ?, but the query string always starts with q=

The above url should look something like:-
Code:
http://www.mydomain.com/admin/settings/clean-urls

So that each index.php?q= is removed and you would see a url without the index.php?q= without having rewrite each url individually.
Back to top View user's profile Send private message
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Tue Sep 18, 2007 12:44 pm    Post subject: Reply with quote

usalabs wrote:
each of the query strings '?' has a line of different code after the ?

Because there'll be to many to individually rewrite every query string, all I'm looking for is a rewrite to remove the ? on all query strings in the url

For example. this url:-
Code:
http://www.mydomain.com/index.php?q=admin/settings/clean-urls

opens part of an admin section of a CMS site, each click on a link in the admin area has a different string after the ?, but the query string always starts with q=

The above url should look something like:-
Code:
http://www.mydomain.com/admin/settings/clean-urls

So that each index.php?q= is removed and you would see a url without the index.php?q= without having rewrite each url individually.


I think that you are looking at url rewriting the wrong way!

On your site you would have to have all your urls pointing to http://www.mydomain.com/admin/settings/clean-urls

and then set up url rewriting to point http://www.mydomain.com/admin/settings/clean-urls to http://www.mydomain.com/index.php?q=admin/settings/clean-urls

Code:
$([a-zA-z0-9]*/?) -> index.php?q=$1

_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Tue Sep 18, 2007 10:38 pm    Post subject: Reply with quote

roganty wrote:
Code:
$([a-zA-z0-9]*/?) -> index.php?q=$1


virtual path regular expression: ^/([a-zA-Z0-9/]*)
case sensitive: unchecked
conditions: none
apply to sub-requests: can be unchecked
if the rule matches: internal redirection
redirect to: /index.php?q=$1
next action: stop matching
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group