rewrite rule for files with pattern to go to subdirectory - wordpress

I have files with this pattern :
(a[0-9]+\.htm)$
Considering file names a1180717200.htm or a1245862800.htm : normally they would be in root for the domain I am working with. Instead they have been moved to a new directory /archives so the files are now in :
thedomainiamworkingwith.com/archives/a1245862800.htm
I have tried a few things but I have no success. The root is occupied by a working wordpress site, with its normal .htaccess file set up. So I need to know what the redirect or RewriteRule would be, as well as how to put it in the .htaccess file without messing up the current wp install.

Are you trying to redirect your pages of this pattern to archives directory?
You can try something like this
RewriteRule ^(a[0-9]+.htm)$ thedomainiamworkingwith.com/archives/$1 [R=301,L]

Related

Elgg with within subdirectory that is not executed by elgg

I have website that run elgg in root directory.
But I want into subdirectory that is located within elgg put wordpress site.
Example:
www.mysite.com - elgg,
www.mysite.com/wp - wordpress
Yes, and I don't need any kind of integration between them (no bridge)
Just to elgg not to execute this folder
So I need for directory www.mysite.com/wp different rules than for rest site.
I tried changing .htaccess file for www.mysite.com/wp directory, but I think it's wrong way.
It is working only for simple .php files, but wordpress is more complex and after long period of loading It show elgg "nothing found" site loaded.
Please don't ask change site structure, it is already set. And wordpress in subdirectory also has it's reasons.
I know there must be easy solution for this issue like elgg plugin for subdirectories, but problem is that web is flooded with topics about installing elgg in subdirectory and I can't find solution.
You can use a rewrite rule that uses ^$ to represent the root and rewrite that to your /wp directory, and write this just above index.php like this:
RewriteEngine On
RewriteRule ^wp(.*)$ /wp [L]
RewriteRule ^(.*)$ index.php?__elgg_uri=$1 [QSA,L]

Move All Files in One Folder and htaccess Redirect to Them?

I have a bunch of old static html sites. I want to install wordpress in the root on every site, but still keep the old pages. So I want to somehow automate this process for every single file:
Group and Move all files into a single folder (all html into \files, all media into files\media css into files\css and so on)
Create rules in htaccess to redirect all of the original URLs of those files to their new respective paths in the new folder. Example:
website.com/category1/file1.html MOVED to website.com/files/file1.html
.htaccess rule:
RewriteRule ^category1/file1.html$ files/file1.html [L]
I need to do this for 30+ sites with many files. Is there a way to somehow automate this process?
This should work:
RewriteRule ^category1/(.*)$ files/(.*) [R=301,L]
That will redirect website.com/category1/file1.html to website.com/files/file1.html.

Changing the Display URL Using Mod Rewrite

I need to change the display URL from
www.site.com/blog/events/
to
www.site.com/events/
I have installed WordPress in
/blog/ directory and have installed a plug-in for /events/ for dynamic event management.
Basically, I want to get rid of /blog in the URL when /events/ occurs in the URL.
I have tried various rewrite rules using .htaccess file but none of the rules worked out.
Also, there are 2 .htaccess files (the first .htaccess file is the default file found in the root path of the web server and the other is the default WordPress .htaccess file presents inside /blog/ directory).
I am little confused on which .htaccess file I need to try the URL mod rewrite rule.
How to do this using URL mod rewrite conditional rule?
Please help me to see the light. Any support would be greatly appreciated!
Thanks in advance...
Try this code in htaccess root directory :
RewriteEngine On
RewriteRule ^events/(.*)$ /blog/events/$1
The first line allows you to rewrite url. The second line check if the url begin with "events/", and if it's the case, the server is going to look files in the real "blog/events/" directorie.

WordPress pages outside install directory

I have WordPress installed in a subdirectory and I'd like one WordPress page to appear as if it's on the root.
Eg.
/wordpress/mypage
To appear as:
/mypage
Assuming you're on Apache, and you've got permalinks already working, you can use an .htaccess file in your document root to rewrite yoursite.com/wordpress/mypage to yoursite.com/mypage.
If you don't already have a .htaccess file in your document root, create one and put this in:
RewriteEngine on
RewriteRule ^mypage$ wordpress/mypage
I'm no .htaccess expert, but that should do the trick.

Installing Wordpress along side Cakephp

I have cakephp installed in the root directory. site.com/
i want to install wordpress blog at site.com/blog
but since cakephp will redirect all urls i am not sure how to do it ?
From: http://dogmatic69.com/blog/development/7-using-other-apps-with-cakephp-htaccess-config
One thing that is asked quite a lot on #cakephp is how to use other apps alongside CakePHP, and the answer giving is normally pretty ugly. Stick the files/folders in side webroot/. Although that does work, its not very nice. So ill show you a little trick with .htaccess files.
The first (really simple way) is to use a .htaccess inside the sub folder. For example you can have a copy of Joomla! running alongside cake with no issues when you have the .htaccess for Joomla! enabled. If the app does not have one and/or you would not know what to put in the .htaccess file you have another option
Make Apache stop processing rewrites if it finds a request for your sub directory. This is done by adding a rule for the sub directory and then telling Apache it is the last rule to process. The .htaccess file you want to edit is the one found inside your APP directory. All you want to add is the following line:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (some_folder/.*) $1 [L] # adjust the regex to what you want.
# normal cake rules
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
You can do this for as many sub folders as you wish, by changing the regex accordingly. Its pretty simple to do and a much cleaner way than having all your stuff inside the webroot/ folder of your APP.
Simply put the wordpress install into a "blog" folder in your /app/webroot folder.
Cake will load from the webroot as if the files were in a normal subfolder under a non-cake appliation. You may need to edit / adjust paths in the wp configs or .htaccess files throughout to get everything perfect but it isn't that difficult.
One way to do this is to have your domain pointing to site.com/cakefolder and then have another subdomain blog.site.com pointing to site.com/blog folder
This way to your user, it would always be site.com and blog.site.com

Resources