How to rewrite directories into query string - .htaccess

Yay, my first Stackoverflow question ever! Been around for years but this one gets me.
I have an URL:
https://example.com/site.com/phpBB3/general-f1/things-are-getting-crazy-here-t948-60.html
(I need to test this locally first which is why I have set it this way)
I want to change the URL into:
https://example.com/site.com/phpBB3/viewtopic.php?f=1&t=948&start=60
I have my .htaccess file in /example.com/.htaccess and the content is:
RewriteEngine On
RewriteRule ([a-z0-9_-]*-f)([0-9]+)\/([a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ viewtopic.php?f=$2&t=$4&start=$6 [QSA,NE,L,NC]
I have AllowOverRide set and the rewrite mod is enabled.
This seems to work in https://htaccess.madewithlove.be/
but not at the actual site. I'm going crazy. What's wrong with me?

This helped me to solve my problem https://techtitbits.com/2008/10/phpbb-redirect-broken-links-after-uninstalling-an-seo-mod/

Related

I am not sure if my .htaccess is wrong or if the server didn't read my .htaccess file yet

I am pretty certain, that my code is alright, for a briefly moment, my htaccess seems to work when i entered an url. After I extended the file and reuploaded it, my Rule didn't work any more. Even when I removed my edit the Rewrite Rule don't triggert any more.
Did i miss something in my Rule. I don't get it whats wrong right now.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^www\.sub\.domain\.de\/(.*)\.html$ www.sub.domain.de/typo3/$1.html?&%{QUERY_STRING}
</IfModule>
Okay. My first mistake was the complete url as first param in RewriteRule.
After I followed Kaddath's instuctions the rewrite kinda worked. I still had a problem with a loop call. The htaccess appendes planty "typo3/typo3/...", so that a RewriteCondition has to solve this. I checked if the url has already typo3 in his string. Now the Url is correctly rewritten.
I also tried [L] before to stop a looping rewriteRule, but it didn't help.
Thank you Kaddath for giving the right clues.

htaccess file help needed for rewriting url

I need help from experts to solve my problem. I'm just starting to learn rewriterule, rbase, and rcond. I want to rewrite my site link like codeigniter MVC. For example:
http://localhost/app/index.php?page=profile&user=john -> http://localhost/app/index/page/profile/user/john
How to do that? I tried to change for many times, but i don't get url like that but error occured.
RewriteRule ^index/page/(.*)/user/(.*)$ /index.php?page=$1&user=$2 [L]

Looking for answer about Clean URLs that I have not found thus far

I am looking to clean up my URLs and I am having the most difficult time. I have an Apache server on GoDaddy. Not sure if hosting is the problem. I've uploaded many .htaccess files and none have worked.
Goal: I am trying to eliminate ".php" completely from my site.
Example: http://example.com/about.php and http://example.com/folder/anotherpage.php
I want it to read http://example.com/about and http://example.com/folder/anotherpage
How do I write a .htaccess file for this? All of the answers I've found deal more with parameters.
and nothing I've done seems to work. Is this a GoDaddy issue? Please help. Thanks in advance.
I think it should be as follows:
RewriteEngine On
RewriteRule about about.php
RewriteRule folder/anotherpage folder/anotherpage.php

Removing "feed" folder in htaccess

I've looked everywhere and cannot figure this out and appreciate anyone's help on this:
I have several links that need to be redirected and they look like this:
http://www.DOMAINNAME.com/about-us/feed
I just want to remove the folder "/feed" in those URLs and everything I have tried doesn't work:
RewriteRule ^about-us/feed$ http://www.DOMAINNAME.com/about-us [R=301,L]
Also does not work:
redirect 301 about-us/feed http://www.DOMAINNAME.com/about-us
Thanks again for the help. I have a LOT of other redirects to do but will start here. I normally don't have any issues with these but for whatever reason these are causing me some issues. Plus it's Monday so I'm sure that doesn't help any :)

htaccess mod_rewrite directory to variable

I'm having some trouble with mod_rewrite in my .htaccess file.
I've found numerous tutorials about how to do the reverse of what I'm trying to accomplish.
Basically I need a solution to change directories to get variables.
So that this:
http://example.org/page-1
turns into
http://example.org/?link_id=page-1
I think I got a code that would do something almost to what I need, but I was getting redirect loops.
Here you go:
RewriteEngine On
RewriteRule ^page-([0-9]*)$ index.php?link_id=page-$1
Note: I'm not sure that index.php is your DirectoryIndex. If it's not, you should change it according to your index file.

Resources