Rewrite profile URL making whole page glitch and break - .htaccess

Alright I've searched and looked at at least 20 ways to turn site.com/profile?page=username
to just site.com/username
and they DO work, but when I do it and go to the page it starts off loading normal, then completely glitches and continues to glitch and break the page.
I really don't know what to do at this point. I don't know if it's just GoDaddy and I need something specific or what.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/([^/]+) /profile.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?page=$1
is the current one i've tried
Solved
I ended up finding someone who posted this, and it worked!
RewriteRule ^([^/]*)/$ /profile.php?page=$1 [L]

Related

Rewrite URL with just company name with current htaccess file

First I like to say I feel so privileged being here. I have used the answer given here for many years and it has saved me many many hours. I have searched for the answer to my current question with no luck. I believe the answers didn't work because I am adding it to my current .htaccess file which is required. I have asked in my current software program (phpfox) forum but they said it could not be done. I will leave it to stackoverflow experts to tell me whether it can be done or not. Here is my current .htaccess file
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(file)/(.*) PF.Base/$1/$2
RewriteRule ^static/ajax.php index.php
RewriteRule ^themes/default/(.*) PF.Base/theme/default/$1
RewriteRule ^(static|theme|module)/(.*) PF.Base/$1/$2
RewriteRule ^(Apps|themes)/(.*) PF.Site/$1/$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
Here are three examples of the URL for this business page.
DomainName/directory/detail/302/name-of-business/overview/
DomainName/directory/detail/302/name-of-business/aboutus/
DomainName/directory/detail/302/name-of-business/contactus/
I think you get the picture but just in case here is a different business.
DomainName/directory/detail/303/name-of-business/overview/
Now for this business page the /directory/details never changes. The 302 is the primary id of the record in the database table for this business. In that same record is the name-of-business. So if I type in the browser URL DomainName/directory/detail/302 it will still bring me to main overview page even without "name-of-business/overview" at the end of the URL. So I am assuming the php code throws that at the end of the url from the database depending on what menu you click on this specific business.
My dream hope is getting it down to
DomainName/name-of-business/overview
DomainName/name-of-business/contact etc...
But I would even be happy to get rid of at least directory/detail (I am guessing the id "302" is needed since it is the main identifier...just guessing).
DomainName/302/name-of-business/overview
I have tried many different answers here but I feel I also may be putting it on the wrong line in my current .htaccess file. Thank you in advance for any help and your time.
Try with:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(file)/(.*) PF.Base/$1/$2
RewriteRule ^static/ajax.php index.php
RewriteRule ^themes/default/(.*) PF.Base/theme/default/$1
RewriteRule ^(static|theme|module)/(.*) PF.Base/$1/$2
RewriteRule ^(Apps|themes)/(.*) PF.Site/$1/$2
# Rewrite DomainName/303/... to DomainName/directory/detail/303/...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d+)(/.*|$) index.php?q=directory/detail/$1$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
Rewrite DomainName/303/... to DomainName/directory/detail/303/...
but only for external links or once fixed in your pages

.htcaccess rules not working properly

I encountered a small issue while trying to make my site redirect all http requests to https. Before I start, however, I should warn you that I'm rather new to this, so please show mercy ;)
Here's my htcaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://nordicraft.net/%{REQUEST_URI} [NC]
To start off, I'm runing my site on shared hosting, and the everything to the first RewriteRule was in the file the first time I opened it. I have no idea what the -d and -f conditions mean or what are they supposed to do, so I left them untouched. The only things I added were the last RewriteCond and RewriteRule.
Now, the issue is, it works as intended ONLY when accessing the main page, that is, simply entering nordicraft.net in the address bar. It redirects me to the https version, as intended. Also, it does the same thing if I explicitly try to access the index.php file. However, if I try accessing any other website feature, like the forums, it redirects me to https://${REQUESt_URI}. In my case, https://forum. You can view the site in real time at http://nordicraft.net.
Any ideas what is causing this, or possible fixes? Thanks!
Try with:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://nordicraft.net%{REQUEST_URI} [NE,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ /index.php [L]

mod-rewrite forwarding without changing URL

I have a small problem with my Apache configuration when creating "pretty" URLs. I've got it to the stage where typing (or linkig for that matter) to
index.html
forwards you to
index.php?pageID=Forside
that is exactly what I want.
But how can I get index.html to stay in the address bar of the browser?
Right now it forwards and changes the URL to the original one.
Here my .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} index\.html
RewriteRule .* http://www.radoor-designs.dk/index.php?pageID=Forside [L]
And before someone comments on it: Options +FollowSymLinks is missing since it triggers an error 500 on a one.com webhotel.
Thanks in advance!
Try the following:
RewriteEngine On
RewriteRule ^index\.html$ /index.php?pageID=Forside [L]
I think this may help you to resolve your problem.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.html$ /index.php?pageID=Forside [L]
This will do the redirect for you whilst showing index.html in the browser window.
Strange that symbolic links creates an error 500,
if you want it to redirect to index.html?pageID=Forside then do
RewriteRule .* /index.html?pageID=Forside [QSA,L,R=301]
I'm not 100% certain what you are trying to achieve with this could you explain a little more?

htaccess clean url for Joomla component

I give up. I have read through dozens of questions on here, even asked my own, I have tried numerous things, I just don't know what to do anymore.
I need to create url's out of the following formats: (NSFW links, be warned)
http://jbthehot.com/#page=1
http://jbthehot.com/home?func=viewphoto&id=2969
http://jbthehot.com/home?page=4
http://jbthehot.com/home?func=viewalbum&aid=75
I must be retarded because I simply do NOT understand htaccess. I try not to ask for all-done answers, but in this case, an actual clear, copy/paste answer for at least one of the above formats would really be helpful.
I repeat, I have tried a lot of things, so I'm obviously doing something wrong, or I'm not understanding the rules and conditions right, so a copy/paste answer that is SURE to work would really help me understand what I'm doing wrong here.
If it helps, the component used here is SIM Gallery, on Joomla and there are a couple of other rewrite rules in effect in the .htaccess , here they are:
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
Thank you for any help
RewriteEngine On
RewriteBase /
RewriteRule ^home/viewphoto/([0-9]+)$ home?func=viewphoto&id=$1 [L]
RewriteRule ^home/viewalbum/([0-9]+)$ home?func=viewalbum&aid=$1 [L]
RewriteRule ^home/page/([0-9]+)$ home?page=$1 [L]
So http://jbthehot.com/home/viewphoto/2969 would show you http://jbthehot.com/home?func=viewphoto&id=2969, etc

htaccess and turning ?page into /(whatthepageis)

Ok, so I am wondering what is the correct way to do .htaccess so that a url like this
http://www.mysite.com/?page=spinme
looks like this
http://www.mysite.com/spinme
It still needs to load index.php
but I am not sure how to do it, I know sounds simple.
Also I need it not to effect images or style sheets that are already
http://www.mysite.com/(what ever the folder link)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f //not to effect images or style sheets
RewriteCond %{REQUEST_FILENAME} !-d //not to effect directory's
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
To make
http://www.mysite.com/?page=spinme
to look like
http://www.mysite.com/spinme
You first of all need to make each output of that URI to be
http://www.mysite.com/spinme
That step is very important (at least for the display, in terms of working, you can skip this step and your site will just work).
If you've managed that, in your .htaccess file, just add a single rule:
RewriteRule ^spinme$ index.php?page=spinme [L]
and you're done.
If you're concerned about Search Engine Optimization (SEO) you should use this URI instead:
http://www.mysite.com/?page=spinme
It will show the search engine that your site has pages and they have a name. That's additional information searchengines process nowadays, comparable to keywords in earlier days.
Hope this is helpful.

Resources