Good day there is a link gallery.php? Gallery = test I want to change to gallery / test but it does not work, but for example, gallery = test changes

RewriteRule ^gallery=(.*)$ gallery.php?gallery=$1 [L] 

Do so

 RewriteRule ^gallery/(.*)$ gallery.php?gallery=$1 [L] 

the page fails to open without any css and js files and the links on the page are not correct. The slash is not screened either. But I don’t know if I’m doing it right

 RewriteRule ^gallery\/(.*)$ gallery.php?gallery=$1 [L] 

    4 answers 4

    So. Your second choice is correct.

     RewriteRule ^gallery/(.*)$ gallery.php?gallery=$1 [L] 

    And you have left JS and CSS because you have given them relative paths. I.e:

     <script type="text/javascript" src="js/script.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css" /> 

    It's wrong

     <script type="text/javascript" src="/js/script.js"></script> <link rel="stylesheet" type="text/css" href="/css/style.css" /> 

    It is right.

    Look for the difference and correct all relative paths to absolute ones. Then everything will work. It will not be - give a link, I'll stick you where you have not corrected.

    • Generally it turns out interesting ... <br> question about mod rewrite and the answer is about ways ^^ - Zowie
    • I changed, but did not help, you can contact by mail and yourself, take a look? (r-unix@mail.ru) - Royal
    • <b> just no comments ^^ </ b> - Zowie
    • Mail is in the profile. - Sh4dow
    • Thanks, Sh4dow solved the problem by setting <link rel = "stylesheet" type = "text / css" href = "folder / css / style.css" /> and don’t be surprised I’m still not Russian, so I cann’t ask correctly - Royal

    So:

     RewriteRule ^gallery/([a-zA-Z0-9]+)$ /gallery.php?gallery=$1 [L] 

    And styles and scripts should be specified relative to the site root, for example: <link href = "/ css / style.css" ...

    • no it didn't work - Royal
     RewriteEngine On RewriteRule ^gallery/([a-zA-Z0-9]+)$ gallery.php?gallery=$1 [L] 
    • And just tell me what does not work) checked! ) - Ozim
    • No, it does not work either. - Royal
    • <b> Ozim </ b> isn’t it obvious that aftar is generally 0, cannot form a normal question, and all that can do is stupidly try what they put under his breath? - Zowie
    • A well-formed question, I simply cannot understand what the problem is. Why when using slashov displays an error. - Royal
    • one
      O_o I am not a topic starter, but if I were, I would have opened my veins ... - Zowie
      RewriteRule ^galery\/([a-zA-Z0-9]+)\/?$ /galery.php?galery=$1 [L] 

    And so?

    • No, and so does not work. - Royal
    • Your paths are crooked, Dem correctly wrote the paths so you need to prescribe the layout of the page, i.e. from the root, i.e. at first, always and everywhere, a slash ... Links need to be formed as well, nothing to do with htaccess, if you worked before (and it was a redirect) - all other problems are already looking in your ways;) <br> PS: You really need to? :) - Zowie
    • Yes, I didn’t help everything, and the rewriterule works for me RewriteRule ^ gallery = (. *) $ Gallery.php? Gallery = $ 1 [L] this is no problem and there isn’t any RewriteRule ^ gallery /(.*)$ gallery.php ? gallery = $ 1 [L] - Royal
    • I hope you thought of changing galery to a gallery? ^^ - Zowie
    • @AlexWindHope> the page opens without any css and js files. Doesn't this say anything to you?) Lol - Sh4dow