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!
| SitePoint Sponsor |
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!
i want to use .htacess but i don't know whether it can achieve it.

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).
If you don't understand what I did, PLEASE read the mod_rewrite tutorial article linked in my signature ("Article") before you ask questions.Code:# .htaccess in DocumentRoot RewriteEngine on RewriteRule ^([a-z]+)\.xhtml$ index.php/term/$1 [L]
Regards,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
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 ?

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,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
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.
redirect 301 /index.php/term/bo.xhtml http://example.com/bo.xhtml
try this

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,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
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.

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,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks