0

I have a URL:

"http://www.example.com/pages/about.html"

I've been able to get rid of the file extensions and add a "/" at the end to create:

"http://www.example.com/pages/about/"

using:

RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.html RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] 

Next, I need to remove the pages subdirectory folder from the URL so that I get:

"http://www.example.com/about/"

2
  • Not possible.. You can get /services/service1/ and /about/ , but not /service1/ and /about/. You need to keep the /services/ before service1 otherwise it'll break Commented Feb 28, 2012 at 17:23
  • Ok, I'll add everything in the services folder to the pages folder and delete the services folder. What code do I add to .htaccess file and do I put it before or after the current code I have? Commented Feb 28, 2012 at 17:27

1 Answer 1

1

If you don't want /services/ before your services, then you'll have to move your service pages to the "pages" folder where your other files are, and then replace

RewriteRule ^([^/]+)/$ $1.html RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html 

with

RewriteRule ^([^/]+)/$ /pages/$1.html 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.