Helpful Information
 
 
Category: General Info
Mod_rewrite

After reading your detailed manual and faq's I ended up having only one unanswered simple question and that is


Can I use Mod_rewrite in a .htaccess file on any of the web hosting packages, are their any restrictions?

Some hosting companies I have recently hadto deal with does not allow but I am assuming that because of your server set up their are no restrictions.

Regards

:)

Hello,

You can use that and there are no restrictions. The best place to go for support with that is apache. We are running a standard version of apache and so anything that you can find within their help documents will apply to your account. If there is anything else I can help you with please let me know.

Hi,

I have a question on the mod_rewrite also.
On the URL http://forum.urlaubsreise.info I use phpbb, as it is used here.
Now I have installed a mod, that rewrites all dynamic pages to static html. The links in the forum are now pointing to .html, so that is okay. But when clicking on any .html link a 404 error occurs.
I have tried several .htaccess files now and it works with none of them. Do you see any error in the following .htaccess ?
BTW: I upload those .htaccess to the root directory of the forum.


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} /phpbb/forums.*
RewriteRule (.*) /phpbb/index.php

RewriteCond %{REQUEST_FILENAME} /phpbb/viewforum([0-9]*)-([0-9]*)-([0-9]*).*
RewriteRule (.*) /phpbb/viewforum.php?f=%1&topicdays=%2&start=%3

RewriteCond %{REQUEST_FILENAME} /phpbb/forum([0-9]*).*
RewriteRule (.*) /phpbb/viewforum.php?f=%1

RewriteCond %{REQUEST_FILENAME} /phpbb/ptopic([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1&view=previous

RewriteCond %{REQUEST_FILENAME} /phpbb/ntopic([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1&view=next

RewriteCond %{REQUEST_FILENAME} /phpbb/ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1&postdays=%2&postorder=%3&start= %4

RewriteCond %{REQUEST_FILENAME} /phpbb/ftopic([0-9]*)-([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1&start=%2

RewriteCond %{REQUEST_FILENAME} /phpbb/ftopic([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1

RewriteCond %{REQUEST_FILENAME} /phpbb/ftopic([0-9]*).*
RewriteRule (.*) /phpbb/viewtopic.php?t=%1&start=%2&postdays=%3&postorder= %4&highlight=%5[/quote]

thanks in advance
greg

the above post is not correct, the phpbb folder in it does not exist.
the correct version is

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} forums.*
RewriteRule (.*) /phpbb/index.php

RewriteCond %{REQUEST_FILENAME} viewforum([0-9]*)-([0-9]*)-([0-9]*).*
RewriteRule (.*) /viewforum.php?f=%1&topicdays=%2&start=%3

RewriteCond %{REQUEST_FILENAME} forum([0-9]*).*
RewriteRule (.*) /viewforum.php?f=%1

RewriteCond %{REQUEST_FILENAME} ptopic([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1&view=previous

RewriteCond %{REQUEST_FILENAME} ntopic([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1&view=next

RewriteCond %{REQUEST_FILENAME} ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&start= %4

RewriteCond %{REQUEST_FILENAME} ftopic([0-9]*)-([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1&start=%2

RewriteCond %{REQUEST_FILENAME} ftopic([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1

RewriteCond %{REQUEST_FILENAME} ftopic([0-9]*).*
RewriteRule (.*) /viewtopic.php?t=%1&start=%2&postdays=%3&postorder= %4&highlight=%5

but it does not work either.

djgreg,

There are multiple problems. First is that mod_rewrite's work best in the virtualhost directives not in .htaccess files. Second, why rewrite the static links back to the dynamic ones? Why not just remove the static page builder module? Third, %{REQUEST_FILENAME} is the full path to the files, which your condition does not check for.

This works (I set this up in your VirtualHost for forum in /etc/httpd/conf/httpd.conf):
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} .*/forum([0-9]+).html
RewriteRule (.*) /viewforum.php?f=%1

It's not perfect, but it does work and it should hopefully show you the path to follow to find the best solution to this problem.










privacy (GDPR)