0
RewriteEngine On RewriteRule ^/showlisting/(.*)$ showlisting.php/$1 [L] RewriteRule ^/listings/(.*)$ listings.php/$1 [L] RewriteCond %{HTTP_HOST} ^mydomain\. RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] ErrorDocument 404 /notfound 

In the above, this is what I want to achieve:

  1. I want to forward any URLs such as www.mydomain.com/showlisting/my-listing-data/with-more-slashes/and-some-text to show the content of www.mydomain.com/showlisting*.php*/my-listing-data/with-more-slashes/and-some-text but with URL masking so that the .php does NOT appear on the browser window.
  2. I also want to append with www when the www is not present in the request for SEO purposes, although I'm not sure how important this is these days.

When I visit www.mydomain.com/showlisting/my-listing-data/with-more-slashes/and-some-text however it shows a 404 error, but with the .php added to showlisting, it works fine. Any ideas?

However note that the appending of the www. works fine - that's not the part I'm struggling with, although I included that part of the code anyway for full analysis.

3
  • 1
    in which directory is the .htaccess file located? Commented Apr 10, 2012 at 19:51
  • Ensure the slashes are synched. It's either w/o for the rule regex, or with for the substitution. Commented Apr 10, 2012 at 19:53
  • Everything is under the public_html folder. All .php files, the .htaccess etc. Commented Apr 10, 2012 at 19:57

1 Answer 1

1

Maybe

RewriteEngine On RewriteRule ^showlisting/(.*)$ showlisting.php/$1 [L] RewriteRule ^listings/(.*)$ listings.php/$1 [L] RewriteCond %{HTTP_HOST} ^mydomain\. RewriteRule ^$ http://www.mydomain.com/ [R=301,L] ErrorDocument 404 /notfound 
Sign up to request clarification or add additional context in comments.

1 Comment

no luck - changed it according to your specs. I should specify that the www. appending works just fine. It's the .php issue that doesn't work at the moment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.