Jump to content

Recommended Posts

Hi,

 

I have a question regarding .htaccess.

 

I'm attempting to make pretty URLS. I'm almost half way there but I can't quite seem to figure how to add a "dash" - to certain keywords.

 

On the below page

http://whatsmyowncar...cle-display.php

 

How would I turn

http://whatsmyowncar...th.com/new york

into

http://whatsmyowncarworth.com/new-york

 

Below is my .htaccess file. Any help would be appreciated. Thanks.

 

 

RewriteEngine On
RewriteRule ^([a-zA-Z_]+)$ state.php?state=$1 [L]

Link to comment
https://forums.phpfreaks.com/topic/272007-htaccess-question/
Share on other sites

Hey Marcus,

 

Thanks for the help. I did what you said and the URL links work now but the data isn't showing up on my website. Could this be because of the htaccess file?

 

http://whatsmyowncar...om/rhode-island

http://whatsmyowncarworth.com/new-york

 

 

RewriteEngine On
RewriteRule ^([-a-zA-Z_]+)$ state.php?state=$1 [L]
RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)$ city-breakdown.php?state=$1&city=$2 [L]

Edited by scm22ri
Link to comment
https://forums.phpfreaks.com/topic/272007-htaccess-question/#findComment-1399569
Share on other sites

If your script uses the GET parameter to find the city, and you haven't updated your scripts to handle the change from " " to "-", then kind of: It's not because of the .htaccess itself, but the changes you did to enable its use.

In any case, you'll have to verify the received GET-parameters against what your code expects, and either make the code replace the hyphen with a space or (even better) save the new link-title in the DB and use it instead.

Link to comment
https://forums.phpfreaks.com/topic/272007-htaccess-question/#findComment-1399586
Share on other sites

Hey Guys,

 

Thanks a lot for helping me out with .htaccess. It's working but for some reason my CSS isn't working? It seems the city pages aren't displaying properly.

 

I'm not sure what the problem is, could it even be my CSS? or perhaps it's my .htaccess?

 

What do you guys think?

 

(state page is fine)

http://whatsmyowncarworth.com/rhode_island

 

(city pages aren't displaying my CSS)

http://whatsmyowncarworth.com/rhode_island/cranston

http://whatsmyowncarworth.com/rhode_island/cumberland

http://whatsmyowncarworth.com/rhode_island/east_providence

http://whatsmyowncarworth.com/rhode_island/east_greenwhich

http://whatsmyowncarworth.com/rhode_island/exeter

Link to comment
https://forums.phpfreaks.com/topic/272007-htaccess-question/#findComment-1399739
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.