SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: alter the url
-
Dec 6, 2009, 23:40 #1
alter the url
there is a url
http://example.com/index.php/term/bo.xhtml.
now i want to make it turn into http://example.com/bo.xhtml. how should i do,do use rewrite can ? any tips would be appreciated!Outdoor tools online store and wargame tools shop
with best quality and service.
comp molle tactical vest tactical clothing etc sell
-
Dec 7, 2009, 00:16 #2
i want to use .htacess but i don't know whether it can achieve it.
Outdoor tools online store and wargame tools shop
with best quality and service.
comp molle tactical vest tactical clothing etc sell
-
Dec 7, 2009, 01:25 #3
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
red,
The only way that you can use index.php/term/bo.xhtml is to use Options +MultiViews. IMHO, it's a poor technique (to embed the script's filename in the middle of a URI).
To "make it turn into bo.xhtml," create the links properly in your scripts!
Okay, you're using the common misconception that mod_rewrite creates the "revised format" of the URI by guessing what your intention is. It does not! You must create the format of the redirection (the visible script) then generate regex to provide to mod_rewrite to enable Apache to serve a file (obviously, your intent is to serve index.php, not bo.xhtml).
Code:# .htaccess in DocumentRoot RewriteEngine on RewriteRule ^([a-z]+)\.xhtml$ index.php/term/$1 [L]
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
-
Dec 7, 2009, 03:05 #4
thanks for you answer.i copied and pasted you code to my .htacess file, there is no change on the url.
the solvation of my problem is make a url redirection in .htacess file or make a url rewrite in .htacess file ?Outdoor tools online store and wargame tools shop
with best quality and service.
comp molle tactical vest tactical clothing etc sell
-
Dec 7, 2009, 04:41 #5
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
red,
The code I supplies will take "files" in the DocumentRoot (of the request) with an xhtml extension and redirect (silently) to index.php/term/{extensionless_file_name_of_the_xhtml_doc}. If you want visitors to see the redirection (), then change [L] to [R=301,L].
Didn't you read the tutorial?
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
-
Dec 7, 2009, 05:03 #6
thank you very much, i will read it right away.which is the solution of my problem? the
url redirection in .htacess file or make a url rewrite in .htacess file ? thank you.Outdoor tools online store and wargame tools shop
with best quality and service.
comp molle tactical vest tactical clothing etc sell
-
Dec 7, 2009, 06:08 #7
- Join Date
- Sep 2009
- Posts
- 95
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
redirect 301 /index.php/term/bo.xhtml http://example.com/bo.xhtml
try this
-
Dec 7, 2009, 14:15 #8
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
seop,
But, bo.xhtml can't be served! Remember, the index.php is the requested script (under Options +MultiViews) so you've done it backward.
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
-
Dec 7, 2009, 19:45 #9
yeap,i tried the way from seop.it didn't work.
dklynn,
can you tell me what is Options +MultiViews and Why do we use options +multiviews in rewrite rules?
To "make it turn into bo.xhtml," create the links properly in your scripts!
what does this line mean ? is that in my question i can't by use url redirect to change the url,in addition,i must do some changes in my sscripts. if this is right,can you tell me why i must do some changes to my scripts.Outdoor tools online store and wargame tools shop
with best quality and service.
comp molle tactical vest tactical clothing etc sell
-
Dec 8, 2009, 00:49 #10
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
red,
MultiViews is a directive to Apache to tell it to serve the filename used in the path, i.e., your index.php script in the URI index.php/term/bo.xhtml. In that URI, I'm sure that you don't have a directory named index.php so MultiViews picks that file and allows it to read the term and bo.xhtml to select the contents to output.
WHERE is Apache (or your visitors) going to find the directories index.php and term then request bo.xhtml? My point was that YOU must create these "fanciful" links (bo.xhtml in your DocumentRoot) within your scripts THEN create the mod_rewrite code to redirect to something Apache can serve (index.php/term/bo.xhtml).
READ THE TUTORIAL! It's all there.
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks