php - How can I create friendly URLs with .htaccess? -
I have a hard time with .htaccess I want to create a friendly URL for the site I'm working on Are ...
Actually I want to change this:
http://website.com/index .php? Ctrl = pelicula & amp; Id = 0221889 http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters
In:
http : //website.com/pelicula/0221889/ http://website.com/pelicula/0221889/posters/
If I want it later, I would also like to know that Like how to add the title of the article at the end of the URL (I am using PHP):
http://website.com/pelicula/0221889/ article-name-name / http : //website.com/pelicula/0221889/the-article-name/posters/
Note: The Stakeworfl flow method is also good for me, for example the url of this question :
http://stackoverflow.com/questions/3033407/htacces-to-create-friendly-urls-help-needed
But you You can put anything after the id and it will also work. By the way:
http://stackoverflow.com/questions/3033407/just-anything-i-want
I used some automatic web tools Used .htacces to create a file, but it is not working properly so I ask for your help.
I would be happy if you could recommend it.
Edit: Based on some answers I found it here:
& lt; IfModule mod_rewrite.c & gt; % {REQUEST_FILENAME} on RewriteEngine RewriteCond! -f Rewrite rules ^ / ([^ /] +) / ([^ /] +) /? ([^ /] *) /? $ Index.php? Ctrl = $ 1 and id = $ 2 and tab = $ 3 [QSA, L] & lt; / IfModule & gt;
But I got the default Host 'Page Not Found' error.
I also tried:
& lt; Ifmodule mod_rewrite c & gt; % {REQUEST_FILENAME} on RewriteEngine RewriteCond! -f Reuse rules ^ ([^ /] +) / (\ d +) / ([^ /] +) /? $ Index.php? Ctrl = $ 1 & amp; ID = $ 2 and tab = $ 3 [QSA, L] Rev. Raul ^ ([^ /] +) / (\ d +) /? $ Index.php? Ctrl = $ 1 and amp = id = $ 2 [QSA, L] Remrame rules ^ ([^ /] +) /? $ Index.php? Ctrl = $ 1 [QSA, L] & lt; / IfModule & gt;
This also does not work, it takes me to my default 404.php page.
The mod_rewrite is enabled and working.
Help!
In the root of the document http://website.com/
I will put a htaccess
file in this way:
& lt; IfModule mod_rewrite.c & gt; % {REQUEST_FILENAME} on RewriteEngine RewriteCond! -f Rewrite rules ^ (. *) $ Index.php? Url = $ 1 [QSA, L] & lt; / IfModule & gt;
Then in your PHP script you can manipulate $ _GET ['url']
variable:
$ Path_components = Explosion ('/', $ _GET ['url']); $ Ctrl = $ path_components [0]; $ Id = $ path_components [1]; $ Tab = $ path_components [2];
Comments
Post a Comment