Jump to content

clean url question with .htacess


emehrkay

Recommended Posts

I've done some looking around and I dont know if what I am looking for has been talked about.

 

I have apache running, but it is a shared server (for now) so I figured htaccess would be my only weapon in this matter.

 

What I want to do is use an MVC-like approach but have more than just the index page.

 

So I want the urls to read like

 

site.com/users/emehrkay/bio

 

and before i would impliment the clean url scheme, it would read

 

site.com/users.php?user=emehrkay&section=bio

 

so just like in the first example, you can do site.com/page/var/var with page and var all being variable

 

is that possible? users.php isnt the only page that there will be.

 

Does that make sense? Ill do some more reading on the subject and see if I can find anything.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/49135-clean-url-question-with-htacess/
Share on other sites

Yes, if your server has mod_rewrite installed then you can do it via .htaccess, its a complex rule but it can be done so /page is a page... Which I don't know how to do.

 

Otherwise, you can read $_SERVER["QUERY_STRING"] or something and parse it yourself...

If I am understanding your question correctly, couldn't you do that with something like this in an .htaccess file in the directory your site is at:

 

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^users/(.*)/(.*)/?$ /users.php?user=$1&section=$2

 

...and just repeat rewrite rules like for each different thing you want to do?

If I am understanding your question correctly, couldn't you do that with something like this in an .htaccess file in the directory your site is at:

 

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^users/(.*)/(.*)/?$ /users.php?user=$1&section=$2

 

...and just repeat rewrite rules like for each different thing you want to do?

 

ahh very simple, thank you. now i just need to get my htaccess file working locally so i can test it

  • 2 weeks later...

If I am understanding your question correctly, couldn't you do that with something like this in an .htaccess file in the directory your site is at:

 

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^users/(.*)/(.*)/?$ /users.php?user=$1&section=$2

 

...and just repeat rewrite rules like for each different thing you want to do?

 

ok i used this to replace my query strings, just like you wrote it print_r*$_GET) works fine, the variables are shown. but the page doesnt work anymore. I dont know what the problem is, it seems like it works as it should but without the css. I look at the css editor in the webdeveloper toolbar and it is filled with the page's html. am i doing something wrong?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.