View previous topic :: View next topic |
Author |
Message |
usalabs -
Joined: 14 Nov 2005 Posts: 18
|
Posted: Fri Sep 14, 2007 11:21 pm Post subject: URL rewriting help needed. |
|
|
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 |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Sun Sep 16, 2007 5:56 pm Post subject: |
|
|
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 |
|
|
usalabs -
Joined: 14 Nov 2005 Posts: 18
|
Posted: Tue Sep 18, 2007 9:06 am Post subject: |
|
|
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 |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Tue Sep 18, 2007 12:44 pm Post subject: |
|
|
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 |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Tue Sep 18, 2007 10:38 pm Post subject: |
|
|
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 |
|
|
|