GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech .htaccess rewrite issue (https://gfy.com/showthread.php?t=1357294)

Publisher Bucks 08-26-2022 05:49 AM

.htaccess rewrite issue
 
Can anyone who knows about .htaccess tell me why this is giving me a 500 error?

Its supposed to be re-writing the URLs so they are SEO friendly :Oh crap

Quote:

RewriteRule ^link-name$ link.php?id=link-name [L]
RewriteCond %{THE_REQUEST} ^[A-Z][3,9] /link.php?id=243 HTTP/
RewriteRule ^link.php$ https://www.domain.com/links/link? [R=301,L]
I've placed it as .htaccess in the /links/ directory and the domain root and it still kicks out a 500 error.

When its in the /links/ directory it gives me an error when I click on one of the urls.
When its in the domain root it wont even load the page before kicking out a 500 error.

According to several Google results, this *should* be working perfectly :helpme

k0nr4d 08-26-2022 06:30 AM

That's all so wrong that I don't even know where to start, because I can't figure out what it is you are trying to do from looking at those 3 lines

Publisher Bucks 08-26-2022 07:21 AM

It’s supposed to rewrite from link.php?id=XX

To /links/some-link-name

There’s a ton of sites including Sitepoint threads that say this should work to achieve that.

ravo 08-26-2022 09:35 AM

I'm far from an .htaccess expert, but look at;

https://stackoverflow.com/questions/...o-friendly-url

k0nr4d 08-26-2022 09:51 AM

Quote:

Originally Posted by Publisher Bucks (Post 23036704)
It’s supposed to rewrite from link.php?id=XX

To /links/some-link-name

There’s a ton of sites including Sitepoint threads that say this should work to achieve that.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ links.php?id=$1 [QSA,L]

sarettah 08-26-2022 11:07 AM

Quote:

Originally Posted by Publisher Bucks (Post 23036704)
It’s supposed to rewrite from link.php?id=XX

To /links/some-link-name

There’s a ton of sites including Sitepoint threads that say this should work to achieve that.

That looks bass-ackward to me.

Foe SEO friendly you would have .htacess that rewrites domain/links/link_name to domain/links.php?....

Not the other way around.

.

fuzebox 08-26-2022 12:00 PM

Quote:

Originally Posted by Publisher Bucks (Post 23036704)
There’s a ton of sites including Sitepoint threads that say this should work to achieve that.

:1orglaugh:1orglaugh

Publisher Bucks 08-26-2022 01:24 PM

Quote:

Originally Posted by k0nr4d (Post 23036742)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ links.php?id=$1 [QSA,L]

k0nr4d,

That doesnt do anything when I put it in .htaccess, I was using that originally, then did a search for alternate ways to achieve what I wanted to happen :/

Publisher Bucks 08-26-2022 01:26 PM

Quote:

Originally Posted by sarettah (Post 23036769)
That looks bass-ackward to me.

Foe SEO friendly you would have .htacess that rewrites domain/links/link_name to domain/links.php?....

Not the other way around.

.

I was always under the impression that turning link.php?id=XX to /links/link/-link-name-here/ was a much better option for SEO purposes?

Publisher Bucks 08-26-2022 01:27 PM

Quote:

Originally Posted by ravo (Post 23036735)
I'm far from an .htaccess expert, but look at;

https://stackoverflow.com/questions/...o-friendly-url

Thats actually one of the methods I tried, it works (sort of) but displays the full /root/usr/domain.com/links/link-name-here in the browser.

When editing the rewrite slightly, the most I could get it to do was /links/link/32 (link id number not the title of the link itself).

It also just redirects to my 404 catchall pages content, not the link ids page content :/

zijlstravideo 08-29-2022 11:47 AM

Quote:

Originally Posted by Publisher Bucks (Post 23036812)
Thats actually one of the methods I tried, it works (sort of) but displays the full /root/usr/domain.com/links/link-name-here in the browser.

When editing the rewrite slightly, the most I could get it to do was /links/link/32 (link id number not the title of the link itself).

It also just redirects to my 404 catchall pages content, not the link ids page content :/

But why do you need to take the ID number as a GET query exactly? Why not take the url slug as a query directly? Sounds a lot more straight forward and easier to setup in such way...

For example, just make "domain.com/links.php?id=big-boobies" redirect to "domain.com/links/link/big-boobies". You can skip the whole ID thing, you can get the matching ID number using the slug as well (just look it up from your database).

Or make it work with both the slug and the ID number as query... then let your php code do the magic. If the GET parameter is an integer, connect to your database, find the matching slug first and then go ahead and force redirect to domain.com/links/rick-james-bitch...


All times are GMT -7. The time now is 12:25 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc