0

I've a website with following .htaccess code. The problem is apache (and/or something else) puts more slashes inside urls. For example;

domain.com/blog/blog-post/ (This is what i want)

But this is what i get;

domain.com//blog/blog-post/ or domain.com//about-us//

I've googled it but i didn't reach something usefull. Sorry for my bad English :) Here is the code

Options +FollowSymLinks -MultiViews -Indexes
DirectorySlash Off
RewriteEngine on
RewriteRule ^neler-yapiyoruz/$ index\.php [NC]
RewriteRule ^iletisim/$ contact\.php [NC]
RewriteRule ^biz-kimiz/$ about\.php [NC]
RewriteRule ^blog/$ blog\.php [NC]
RewriteRule ^blog/([a-z0-9-]+)/$ blog_post\.php?slug=$1 [NC]
RewriteRule ^portfolio/([a-z0-9-]+)/([a-z0-9-]+)/$ portfolio.php?catSlug=$1&slug=$2 [NC]
Dekel
  • 60,707
  • 10
  • 101
  • 129
frontxtr
  • 1
  • 2
  • I'm no expert but have messed around with mod_rewrite enough to know (think) that there's nothing in the above that would cause double slashes. All I can suggest is to ensure you are *definitely* not using a cached version, and update your httpd.conf file to output a detailed log file to work out what's going on behind the scenes. More info here: http://stackoverflow.com/a/15137129/3596962. Basically use `LogLevel alert rewrite:trace8` – Ian Jun 21 '16 at 23:54
  • Thanks a lot but also this one didn't solve my problem :( the problem still exists as shown at screenshot here; http://prntscr.com/bjchco – frontxtr Jun 22 '16 at 00:06

2 Answers2

0

You have extra slash in the page to be redirected to part in the URL

So your rule should be

Options +FollowSymLinks -MultiViews -Indexes
DirectorySlash Off
RewriteEngine on
RewriteRule ^neler-yapiyoruz/$ index.php [NC]
RewriteRule ^iletisim/$ contact.php [NC]
RewriteRule ^biz-kimiz/$ about.php [NC]
RewriteRule ^blog/$ blog.php [NC]
RewriteRule ^blog/([a-z0-9-]+)/$ blog_post.php?slug=$1 [NC]
RewriteRule ^portfolio/([a-z0-9-]+)/([a-z0-9-]+)/$ portfolio.php?catSlug=$1&slug=$2 [NC]
DBA
  • 333
  • 2
  • 7
0

Having looked at the source code of the website you showed in the screenshot in your comment, it appears the extra slash is coming from this markup in your HTML:

<base href="http://[domain].com.tr//" />

You should just need to remove the second trailing slash.

Ian
  • 590
  • 2
  • 19
  • The problem is not related with base href. For example when i put files into sub-directory everything goes on well as expected. But when i move files into htdocs folder apache puts more slashes :/ – frontxtr Jun 22 '16 at 13:54
  • Please can you provide an example of this case scenario? With the base href the way it is, every page that the browser is requesting is [domain].com.tr//[request_uri]. With your .htaccess the way it is, nothing is being changed so double slashes would be the expected outcome. – Ian Jun 22 '16 at 14:10