Jump to content

Recommended Posts

Hello. Thanks to all the volunteers who give their time here. You guys are great.

 

I have a question about mod_rewrite. In an effort to clean up my URLs, I've placed the following code in my .htaccess file in the root of my server:

 

RewriteEngine On
RewriteRule /features/(.*) htms/feature-page.php?id=$1 
RewriteRule htms/google.html http://www.blah.com 

 

I know mod_rewrite is working because it successfully takes you to blah.com when you go to the page, htms/google.html. However, the URL is not being rewritten for the 2nd line of code (the line that really matters).

 

Can someone tell me what I'm doing wrong?

 

Thank you again.

Link to comment
https://forums.phpfreaks.com/topic/91127-simple-question-about-mod_rewrite/
Share on other sites

Well, obviously, the one that works has a preceding slash, you might try that.

 

I'd probably do it like this

RewriteRule ^/?htms/google.html$ http://www.blah.com [L,NS]

 

but it's not tested. Basically, ^ is the start of the string, the slash with the trailing question mark makes it optional (just in case the slash isn't passed), it's got your stuff in the middle, and the end of string mark is $

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.