Set Variable and Use in Rewrite Cond
2 posts
• Page 1 of 1
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Set Variable and Use in Rewrite Cond
I might be going about this the wrong way, but I'm at the point where I need to ask.
We have an application that has been running at the root of a website using the mod_seo and mod_rewrite for several years with Ape. We are in the process of moving this application to a subdirectory within the root, but want to simulate the app still running at the root. The app runs everything from a single file call, index.php. While the new root site uses a different default file, index.aspx. We cannot include the index.php in the root as it does several functions to derive the various content requested.
What I have been able to get working is as the last line of code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /clinical-ed-lms/index.php [NC,QSA,L]
However, this then makes the SEO rewrites not work. Here is what I have for the SEO rewrite for several years:
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.cfm\?.+)$ /${SeoURL:$1} [Redirect, Scope=A]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ clinical-ed-lms/${OriginalURL:$1} [NC,L,QSA]
Now, if I comment out the last line of code for the final rewrite:
#RewriteRule (.*) /clinical-ed-lms/index.php [NC,QSA,L]
Then the SEO works fine, but any link that does not have an SEO entry results in the file not found.
My questions are:
1. Is it even possible to do what I'm trying to do?
2. Is it possible to set a variable within the SEO logic that can then be used in the final block of code as a RewriteCond? If so, what would that look like?
Any help will be greatly appreciated.
Thanks,
Marc
We have an application that has been running at the root of a website using the mod_seo and mod_rewrite for several years with Ape. We are in the process of moving this application to a subdirectory within the root, but want to simulate the app still running at the root. The app runs everything from a single file call, index.php. While the new root site uses a different default file, index.aspx. We cannot include the index.php in the root as it does several functions to derive the various content requested.
What I have been able to get working is as the last line of code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /clinical-ed-lms/index.php [NC,QSA,L]
However, this then makes the SEO rewrites not work. Here is what I have for the SEO rewrite for several years:
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.cfm\?.+)$ /${SeoURL:$1} [Redirect, Scope=A]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ clinical-ed-lms/${OriginalURL:$1} [NC,L,QSA]
Now, if I comment out the last line of code for the final rewrite:
#RewriteRule (.*) /clinical-ed-lms/index.php [NC,QSA,L]
Then the SEO works fine, but any link that does not have an SEO entry results in the file not found.
My questions are:
1. Is it even possible to do what I'm trying to do?
2. Is it possible to set a variable within the SEO logic that can then be used in the final block of code as a RewriteCond? If so, what would that look like?
Any help will be greatly appreciated.
Thanks,
Marc
Re: Set Variable and Use in Rewrite Cond
Hello.
You need to move your new rule to the bottom of the configuration file and slightly modify it as follows:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /clinical-ed-lms/index.php [L,NS]
Although I don't really like practice when sites are using such generic rules as this leaves too many possibilities to interfere with legitimate URLs. So please keep in mind that basically everything that is not a file or not found in your SEO database will be rewritten to "/clinical-ed-lms/index.php".
You need to move your new rule to the bottom of the configuration file and slightly modify it as follows:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /clinical-ed-lms/index.php [L,NS]
Although I don't really like practice when sites are using such generic rules as this leaves too many possibilities to interfere with legitimate URLs. So please keep in mind that basically everything that is not a file or not found in your SEO database will be rewritten to "/clinical-ed-lms/index.php".
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest