Mobile app version of vmapp.org
Login or Join
Margaret670

: How to make better RESTful links SEO on static content website with Apache and PHP Router I have a pretty old website (running on Apache) that serves around 50 static HTML pages. And so I

@Margaret670

Posted in: #301Redirect #Apache #Php #Seo

I have a pretty old website (running on Apache) that serves around 50 static HTML pages.
And so I want to change it and add PHP Router to help me serve content in a RESTful way.

Now I have tried several things, but I don't know how good they are.

Say I have old page "domain.com/fooBar.html"
I want to be able to serve it from "domain.com/foo/bar" and:


keep old website link versions accessible from outside: "domain.com/fooBar.html"
make all requests go through index.php where I can use PHP Router, serve proper content for requests, keep old meta tags content intact (RESTful URIs should have same exact data)
NOT have ugly links like this: "domain.com/index.php?page=foo/bar"
keep old version of a website's Google rating somewhat same
keep 301 Redirects to a minimum (2 is max I guess?)
change all website's inner links to new RESTful versions


So far I see that I can reference old pages to index like so:

RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule .* index.php?url=[CO] [QSA,L]


This sends old pages to index.php and I can route Old Resources to New Ones like so:
Changing location with router: $response->header("Location", "/foo/bar");

So the goal is for the location to look like "domain.com/foo/bar":

"domain.com/fooBar.html" => index.php Router => "domain.com/foo/bar"
"domain.com/foo/bar" => index.php Router => "domain.com/foo/bar"


Is there a better way?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Margaret670

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

You have the right idea. The only thing that I would suggest would be to change your rewrite condition somewhat. I would use:

RewriteCond %{REQUEST_FILENAME} !-f # not a real file
RewriteCond %{REQUEST_FILENAME} !-d # not a directory
RewriteCond %{REQUEST_FILENAME} !-l # not a symbolic link


This would prevent the rewrite rule from triggering on index.php (just like your rule does.) It would also allow you to serve other files (such as a robots.txt file, image files, or a pdf file) in the normal static manner.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme