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)
-   -   strange .htaccess issue (https://gfy.com/showthread.php?t=1298616)

freecartoonporn 05-06-2018 09:14 PM

strange .htaccess issue
 
i am trying to rewrite urls on WAMP using .htaccess

i want this

Code:

www.example.com/item/1234
to redirect to this

Code:

www.example.com/item.php?id=1234
so i have this in my .htaccess

Code:

RewriteEngine On

RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]

but now all internal links are prefixed with /item/

this

Code:

<link rel="stylesheet" href="css/style.css">
becomes this

Code:

<link rel="stylesheet" href="item/css/style.css">
this is the first time i am having this kind of issue.,
i have used same config in nginx and it used to work fine on lemp.

but on wamp its screwing all the relative links.

what is wrong ?


i know i can define base url in html, but i want to know what is messing this and why now ?

is it wamp ?


Thanks for your time.

NatalieK 05-07-2018 05:16 AM

If correct, you´re trying to make sure your concealing the directory "item" by opening page item.php...

why not just add page index.php in this directory, thus it always opens when going to this directory & here you can just redirect index.php to item.php :thumbsup

redwhiteandblue 05-07-2018 05:58 AM

Because he probably doesn't want query strings in his URLs, doesn't want to have to physically create the directory and doesn't want to redirect the browser at all? :)

But i don't know anything about using htaccess on WAMP so I can't help. I wouldn't be surprised if the regex is totally different to Linux.

NatalieK 05-07-2018 06:04 AM

Quote:

Originally Posted by redwhiteandblue (Post 22265488)
Because he probably doesn't want query strings in his URLs, doesn't want to have to physically create the directory and doesn't want to redirect the browser at all? :)

But i don't know anything about using htaccess on WAMP so I can't help. I wouldn't be surprised if the regex is totally different to Linux.

true dat.

if it´s not possible, then the simple index.php and redirect is an easy option though :2 cents:

k0nr4d 05-07-2018 06:55 AM

Quote:

Originally Posted by freecartoonporn (Post 22265374)
i am trying to rewrite urls on WAMP using .htaccess

i want this

Code:

www.example.com/item/1234
to redirect to this

Code:

www.example.com/item.php?id=1234
so i have this in my .htaccess

Code:

RewriteEngine On

RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]

but now all internal links are prefixed with /item/

this

Code:

<link rel="stylesheet" href="css/style.css">
becomes this

Code:

<link rel="stylesheet" href="item/css/style.css">
this is the first time i am having this kind of issue.,
i have used same config in nginx and it used to work fine on lemp.

but on wamp its screwing all the relative links.

what is wrong ?


i know i can define base url in html, but i want to know what is messing this and why now ?

is it wamp ?


Thanks for your time.

mod_negotiation - Apache HTTP Server Version 2.4
Try disabling this, you probably have it on.

freecartoonporn 05-07-2018 09:01 AM

Quote:

Originally Posted by k0nr4d (Post 22265514)
mod_negotiation - Apache HTTP Server Version 2.4
Try disabling this, you probably have it on.

still nope.


Code:

Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]


zerovic 05-08-2018 05:17 AM

Hey man,

simply change the way you include your css file

instead of using this

<link rel="stylesheet" href="css/style.css">

add it like this, with a leading slash

<link rel="stylesheet" href="/css/style.css">

if you use it without the leading slash, it will use the current url displayed in the browser.. if you add the leading slash, it will use the root domain

if you still have troubles with it, add this to your .htaccess before the RewriteEngine On command

RewriteRule ^css - [L,NC]

this will completely ignore the css directory from any rewrite rule

ps. tested it, it works

if you can't make it work, feel free to contact me

cheers,
z

freecartoonporn 05-09-2018 05:33 PM

Quote:

Originally Posted by zerovic (Post 22266074)
Hey man,

simply change the way you include your css file

instead of using this

<link rel="stylesheet" href="css/style.css">

add it like this, with a leading slash

<link rel="stylesheet" href="/css/style.css">

if you use it without the leading slash, it will use the current url displayed in the browser.. if you add the leading slash, it will use the root domain

if you still have troubles with it, add this to your .htaccess before the RewriteEngine On command

RewriteRule ^css - [L,NC]

this will completely ignore the css directory from any rewrite rule

ps. tested it, it works

if you can't make it work, feel free to contact me

cheers,
z

this solved my issue.,
Thank you.

Bladewire 05-10-2018 07:19 PM

↑↑↑ Awesome! :banana


All times are GMT -7. The time now is 05:53 AM.

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