• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 URL rewrites without redirecting

#1
I'm in the process of setting up .htaccess RewriteRules for various parts of the site, both to redirect old vb4 URLs and also to preserve some custom parts of the site.

In VB, I was using a custom php file and rewriting to it for a more pleasing URL, e.g.

RewriteRule ^this-looks-nice-for-august-([0-9]+).html?$ mycustompage.php?date=08-$1 [NC,L]

Rather than make a custom PHP file in XenForo, I created an addon to add custom content to a page instead. I made a new RewriteRule like this:

RewriteRule ^this-looks-nice-for-august-([0-9]+).html pages/mycustompage/?date=08-$1 [L]

That doesn't work and results in a "Route this-looks-nice-for-august-2015.html/ could not be found." error. This, however, does work though it redirects to the URL whereas I'd prefer it to keep the more pleasing URL:

RewriteRule ^this-looks-nice-for-august-([0-9]+).html pages/mycustompage/?date=08-$1 [R=301,L]

Thanks for any insight!

- adamsmasher
tonymacx86.com
 
#2
I did a bit more searching and found this article:

ErrorDocument (.htaccess)

I'm guessing it isn't working because XF's default .htaccess prevents any file from "not existing", basically. I added this to top of the default conditions and rules:

RewriteCond %{REQUEST_URI} ^/this-looks-nice-for--([A-Za-z-]+)-([0-9]+)\.html [OR]

It now just throws a 404 error, though still no rewrite. :p

-adamsmasher
tonymacx86.com
 

Mike

XenForo developer
Staff member
#3
You're really fighting against the system with what you're trying to do. You'd probably do better trying to do some custom development in the router to handle the redirect, though I'm not sure exactly what that'd look like off hand.
 
#4
You're really fighting against the system with what you're trying to do. You'd probably do better trying to do some custom development in the router to handle the redirect, though I'm not sure exactly what that'd look like off hand.
Thanks, Mike! I had a feeling I was going about this ass-backwards. I'm stll getting my feet wet with XF.