I have used mod_rewrite in .htaccess (on Apache web server) so that dynamic pages are treated as static html.

The mod_rewrite itself is working fine, so where I had 4 parameters on the URL (php scripts), its now a single html file, eg. product-1-2.html.

However, whilst most of my website is indexed by Google, none of the mod_rewrite html pages are indexed - therefore defeating the objective of using it in the first place.
Does anyone face similar issues, or have any tips / things to check?

I assumed that because it works, ie entering the html based URL does run the dynamic php page and display the correct content - that there was nothing more to it.

Any help appreciated.

Recommended Answers

All 2 Replies

Make sure that you're not using a robots.txt file that might be disallowing spiders to have access to the files. Also make sure you are linking to the mod_rewritten versions throughout your website. If the dynamic URLs are already indexed in the search engines, it might take some time to tell the SEs you want them to use a different URL to access the same page instead. Try using a 301 Redirect from the dynamic versions to their static counterparts.

Heres a part of my .htaccess showing the rewrite rule:

RewriteRule ^property-([0-9]*)-(.*).html /fullpage.php?id=$1&mode=prop&redir=$2 [L]

So, it should be able to take property-1.html and convert that to the php (dynamic) equivalent.

Within my website code, I refer to the links as .html too, as per your suggestion. I can also see that the SEs are not indexing the dynamic versions, nor is there anything in robots.txt to prevent them being indexed.

I do have this within my .htaccess though, and not sure exactly what it does or whether its correct:

DirectoryIndex index.php
Options -Indexes
<Files .htaccess>
order allow,deny
deny from all
</Files>

Any other thoughts?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.